I like the idea to isolate some server services (like MySQL) for example to containers and only provide them to the services needing them (say, SqlUsingApp).
If I understand that right, the usual way would be to have an SqlUsingApp and a MySQL container, linked by running the SqlUsingApp by
docker run --link MySqlContainer:mysql SqlUsingApp
However, if MySQL needs to be restarted, starting the MySQLContainer breaks the link and renders SqlUsinApp useless. This is not the way usual services work, which are linked by ports that can reconnect at any time if one off the services gets restarted. So a usual server with non-dockered services can restart any of them at any time without needed others to be restarted as well.
What is the docker-style solution to this?
Best Answer
I do use
fig
(has now been "renamed" todocker-compose
) to adress this type of problem. One can denote the individual docker containers involved in a "deployment" (as I will call it for now, please anyone: post a comment if you know better terminology. Bear with me, I'm german). This is done in YAML notation in a file namedfig.ylm
(docker-compose.yml
if you have migrated to docker-compose). You are then able to start, stop, etc. the described set of containers via commands likefig start
,fig stop
.The most convenient command to get things running would be
fig up
(builds all contains and starts all of them like a single application with combined console output).To do this in scripts, in a deamon like fashion, the -d parameter is of use:
fig up -d
runs the whole shebang like a single daemon.Link to Fig documentation: http://www.fig.sh
Same for docker-compose: https://docs.docker.com/compose/
I will now post you a complete example of a Gitlab "deployment" consisting of the services Gitlab, Postgres and Redis. It runs on a Ubuntu host, and is started automatically at system boot by an upstart script:
The
fig.yml
(at/root/docker_gitlab/
on host):The upstart script
gitlab.conf
(at/etc/init/
on host):Fig seems to have been so "docker-style", that the docker team incorporated it as docker-compose. So all should be fine in that regard...