Docker:相当于legacy --link参数是什么? [英] Docker: what is the equivalent of the legacy --link parameter
问题描述
我需要将我的数据库容器与我的服务器容器相连。现在我只是关于传统参数链接
,这是完美的
I need to connect my db container with my server container. Now I just red about the legacy parameter --link
, which works perfect
$> docker run -d -P --name rethinkdb1 rethinkdb
$> docker run -d --link rethinkdb:db my-server
但是,如果此参数将被删除最终,我该怎么做如上所述?
But, if this parameter will be dropped eventually, how would I do something like the above ?
推荐答案
该文档说使用docker网络
命令(从Docker 1.9起可用)。 0 - 2015-11-03)
The docs says to use the docker network
command instead (which is available since Docker 1.9.0 - 2015-11-03)
而不是
$> docker run -d -P --name rethinkdb rethinkdb
$> docker run -d --link rethinkdb:rethinkdb my-server
你现在将使用
$> docker network create --name my-network
$> docker run -d -P --name rethinkdb1 --net=my-network rethinkdb
$> docker run -d --net=my-network my-server
请注意,在新窗体中,使用容器名称,而在您可以定义别名之前。
Note that in the new form, container names are used, while before you were able to define an alias.
当两个容器是同一个网络的一部分时,他们的 / etc / hosts
文件被更新,以便您可以使用容器名称而不是其IP地址。
When two containers are part of the same network, their /etc/hosts
file is updated so that you can use the container names instead of their IP addresses.
这篇关于Docker:相当于legacy --link参数是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!