Docker --link时报错,不属于默认网络
高洛峰
高洛峰 2017-04-27 09:01:52
0
2
875

通过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.

是因为在容器内执行的原因吗?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
为情所困

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梦

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!