- 我运行 RancherOS 来运行 docker 容器
- 我在 GUI 上创建了一个容器来运行我的数据库(图像:mysql,名称:r-mysql-e4e8df05)。不同的容器使用它。
- 我可以在 GUI 上将其他容器链接到它
- 这次我想在jenkins上自动创建和启动一个容器,但是链接效果不好
我的命令:
docker run -d --name=app-that-needs-mysql --link mysql:mysql myimages.mycompany.com/appthatneedsmysql
我得到错误:
Error response from daemon: Could not get container for mysql
我尝试了不同的东西:
1)
--link r-mysql-e4e8df05:mysql
错误:
Cannot link to /r-mysql-e4e8df05, as it does not belong to the default network
2)
尝试使用--net
选项
运行:docker network ls
NETWORK ID NAME DRIVER SCOPE
c..........e bridge bridge local
4..........c host host local
c..........a none null local
- 它成功了
--net none
,但实际上它不起作用。该应用程序无法连接到数据库 - 带有
--net host
错误信息conflicting options: host type networking can't be used with links. This would result in undefined behavior
- 带有
--net bridge
错误消息:Cannot link to /r-mysql-e4e8df05, as it does not belong to the default network
它开始continer IP
于:10.XXX
我也尝试过,add --net managed
但错误:network managed not found
我相信我错过了在这个 docker 链接过程中理解的一些东西。请给我一些想法,我怎样才能使这些工作。
(以前当我创建相同的容器并链接到 GUI 中的 mysql 时它正在工作)