通过volume,将docker、docker.sock挂载到jenkins容器中,在该容器内执行
docker run --link redis:redis --name test -d test
报如下错误:
docker: Error response from daemon: Cannot link to /redis, as it does not belong to the default network.
是因为在容器内执行的原因吗?
为情所困2017-04-27 09:03:52
When Docker starts a container, it will create a default network for it - containerName_defaul
,所以使用--link
方式互联容器时由于默认不在一个网络中,会报上述错误,解决办法即添加--net XX_default
, so that the new container and the link target are in the same network.
Reference: http://stackoverflow.com/ques...
过去多啦不再A梦2017-04-27 09:03:52
The reason for executing in a container is of course. Container isolation also includes network isolation. The host network cannot be seen or operated in the Docker container, so it is impossible to connect to other containers located on the host network.