Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking containers together on production deploys

I want to migrate my current deploy to docker, it counts on a mongodb service, a redis service, a pg server and a rails app, I have created already a docker container for each but i have doubts when it comes to start and linking them. Under development I'm using fig but I think it was not meant to be used on production. In order to take my deployment to production level, what mechanism should I use to auto-start and link containers together? my deploy uses a single docker host that already runs Ubuntu so i can't use CoreOS.

like image 240
Carlos Castellanos Avatar asked Jul 02 '14 14:07

Carlos Castellanos


People also ask

Can we link Docker containers?

Docker also has a linking system that allows you to link multiple containers together and send connection information from one to another. When containers are linked, information about a source container can be sent to a recipient container.

What is the command line option getting used to link two containers together?

For an easy solution you could use Docker-compose . in you compose file (docker-compose. yml) use the option links Link to containers in another service. Either specify both the service name and a link alias (SERVICE:ALIAS), or just the service name.

What are two ways to deploy containers?

There are two ways to do this: Directly, with the pull command. Indirectly, during the container deployment process.


1 Answers

Linknig containers in production is a tricky thing. It will hardwire the IP addresses of the dependent containers so if you ever need to restart a container or launch a replacement (like upgrading the version of mongodb) your rails app will not work out of the box with the new container and its new IP address.

This other answer explains some available alternatives to linking.

Regarding starting the containers, you can use any deployment tool to run the required docker commands (Capistrano can easily do that). After that, docker will restart running the containers after a reboot.

You might need a watcher process to restart containers if they die, just as you would have one for a normal rails app.

Services like Tutum and Dockerize.it can make this simpler. As far as I know, Tutum will not deploy to your servers. Dockerize.it will, but is very rough (disclaimer: I'm part of the team building it).

like image 87
Abel Muiño Avatar answered Sep 27 '22 19:09

Abel Muiño