- I run a RancherOS to run docker containers
- I created a container on the GUI to run my databases (image: mysql, name: r-mysql-e4e8df05). Different containers use it.
- I can link other containers to it on the GUI
- This time I would like to automate the creation and starting of a container on jenkins, but the linking is not working well
My command:
docker run -d --name=app-that-needs-mysql --link mysql:mysql myimages.mycompany.com/appthatneedsmysql
I get error:
Error response from daemon: Could not get container for mysql
I tried different things:
1)
--link r-mysql-e4e8df05:mysql
Error:
Cannot link to /r-mysql-e4e8df05, as it does not belong to the default network
2)
Try to use --net
options
Running: docker network ls
NETWORK ID NAME DRIVER SCOPE
c..........e bridge bridge local
4..........c host host local
c..........a none null local
- With
--net none
it succeeds but actually it is not working. The app cannot connect to the DB - With
--net host
error messageconflicting options: host type networking can't be used with links. This would result in undefined behavior
- With
--net bridge
error message:Cannot link to /r-mysql-e4e8df05, as it does not belong to the default network
I also checked on rancher GUI where this mysql runs:
It get a continer IP
startin with: 10.X.X.X
I also tried to add --net managed
but the error: network managed not found
I believe I miss understanding something in this docker linking process. Please give me some idea, how can I make these work.
(previously it was working when I created the same container and linked to the mysql in the GUI)