Multiple docker containers

I am reading about docker and I am trying to figure out if it needs to be something to learn to use.

From what I've read, best practices state that you should have one process per container. Now that means I need one container for JBoss, one for the database, one for storing files, a build server, ...

Now do I need to manually start each of these containers? Or are there some dependencies you can tweak?

How about the order and requirements that a single process in a container can have? JBoss requires the database to start before starting it, etc.

Is this being done?

+3


source to share


1 answer


one process per container

This advice is valid if you want to follow the microservices architecture . microservices have advantages, but also disadvantages. Depending on your situation, you may find it more convenient to have a container with multiple processes.

Running multiple containers on one host

If you want to run multiple containers together on the same docker host, the easiest way is to use fig . The fig config file is very easy to understand as its syntax mimics docker commands. This video gives you a nice presentation of fig (by one of the drawing authors Aanand Prasad)



Note that tools like fig AFAIK won't be able to wait for the first container to start and complete initialization before starting another container depending on the first one. The way to deal with this is to have the 2 nd container implement some kind of test and loop until the dependency is ready and then start its process. This can be achieved through various means (wrapper script, right in your application code, ...)

Running multiple processes in one container

How the docker container will stop as soon as the process is not running in the foreground, you can use various methods ( supervisor , starting the first process as a daemon and the last one in the foreground using phusion / baseimage , ...)

+1


source







All Articles