Docker, and small production server infrastructure advices

I’m figuring out how to setup my production server the best way, but i’m a little bit stuck about how to do it correctly:

Currently, all my web applications are dockerified, i have:

  • ssh-add does not work inside docker image
  • docker compose oci runtime error, executable file not found in $PATH
  • How can I docker-build with Dockerfile?
  • CoreOS : when pulling large docker image of size greater than 4 GB
  • Docker and Chromium net::ERR_NETWORK_CHANGED
  • Building Dockers with Ansible docker_image
    • One nginx front container, that route request to several backend containers:
      • One Symfony App
      • Two WordPress blog
      • One NodeJS App
    • One MySql container for DB storage
    • One MongoDB container too

    ALL this infrastructure is started using docker-compose.

    This works fine but it sounds too much “monolitihic” for me:

    • I cannot stop one container without restarting all the others.
    • I cannot add other web applications without restarting everything
    • I have no way to restart container automatically after a crash…

    This is the first time i’m doing this, do you know some best practices or softwares that can help me to improve my production server ?

    Thanks a lot !

  • Trigger automated Docker Hub build on another public GitHub repo change
  • How can I know which docker will restart after docker daemon restarts
  • Docker volume not mounting on Windows
  • Dockerfile CMD not running at container start
  • Is there a way to force docker-machine to create vm with a specific ip?
  • Codeship: Deploying to EC2 Container Service from Docker Image
  • 2 Solutions collect form web for “Docker, and small production server infrastructure advices”

    I cannot stop one container without restarting all the others.

    What prevents you from using the docker stop command instead of the docker-compose stop command when you want to stop only one container?

    I cannot add other web applications without restarting everything

    I would suggest the use of the excellent jwilder/nginx-proxy nginx docker image to act as a reverse proxy in front of your other containers. This reverse proxy will adapt to the running/stopped containers. You can add a container later on and this reverse proxy will automatically route traffic to it depending on the domain name.

    I have no way to restart container automatically after a crash…

    Take a look at the restart: directive for the docker-compose.yml file.

    The “monolithic” view of docker-compose is indeed made to allow you to manage your application stack in one way. But one needs to know that docker-compose is a “layer” on top of docker which (docker) you can still use.

    As @thomasleveil says, you still can manipulate docker-compose created containers individually with docker.

    $ docker exec project_web_1 ls -l /
    $ docker stop project_db_1
    $ docker up -d project_nginx_1
    $ ...
    

    In another hand I suggest to rely more on docker-compose which also allows to act on individual containers, separate your different applications or environments, and is aware of the dependencies between containers (not being exhaustive).

    $ docker-compose exec web ls -l /
    $ docker-compose stop db
    $ docker-compose up -d nginx
    $ ...
    

    Booting up a new service is also very easy with docker-compose, since it can detect things based on your yml config without stopping anything if not needed.

    $ docker-compose up -d
    project_web_1 is up-to-date
    project_db_1 is up-to-date
    Creating project_newservice_1
    

    I also find the help of a reverse proxy very useful for production installations. However I would more suggest the brand new Traefik which brings nice features like hot-reloading, service discovery, automated SSL certification with Letsencrypt and renewal (not being exhaustive).

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.