How to put docker container for database on a different host in production?

lastoneisbearfood

Let's say we have a simple web app stack, something like the one described in docker-compse docs. Its docker-compose.yml looks like this:

version: '2'
services:
  db:
    image: postgres
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - db

This is great for development on a laptop. In production, though, it would be useful to require the db container to be on its own host. Tutorials I'm able to find use docker-swarm to scale out the web container, but pay no attention to the fact that the instance of db and one instance of web run on the same machine.

Is it possible to require a specific container to be on its own machine (or even better, on a specific machine) using docker ? If so, how? If not, what is the docker way to deal with database in multi-container apps?

Matt

In my opinion, databases sit on the edge of the container world, they're useful for development and testing but production databases are often not very ephemeral or portable things by nature. Flocker certainly helps as do scalable types of databases, like Cassandra, but databases can have very specific requirements that might be better treated as a service that sits behind your containerised app (RDS, Cloud SQL etc).

In any case you will need a container orchestration tool.

You can apply manual scheduling constraints for Compose + Swarm to dictate the docker host a container can run on. For your database, you might have:

environment:
  - "constraint:storage==ssd"

Otherwise you can setup a more static Docker environment with Ansible, Chef, Puppet

Use another orchestration tool that supports docker: Kubernetes, Mesos, Nomad

Use a container service: Amazon ECS, Docker Cloud/Tutum

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to put docker container for database on a different host in production?

From Java

Access host database from a docker container

From Dev

Docker - Run Apache on host and container for different websites

From Dev

Docker container Network connection between different host

From Dev

SSH into a docker container from another container on a different host

From Dev

How does glibc within a Docker image survive different container host kernels?

From Java

How to copy files from host to Docker container?

From Java

How to access host port from docker container

From Dev

How to merge host folder with container folder in Docker?

From Dev

How to mount a directory in a Docker container to the host?

From Dev

How to expose port from host to container in Docker?

From Dev

How to edit Docker container files from the host?

From Dev

How to mount a directory in the docker container to the host?

From Dev

How to connect my host mysql in docker container?

From Dev

How to mount host codes to container in docker?

From Dev

How to map a virtual host to a container in docker?

From Dev

Deploy a docker container to production

From Java

Allow docker container to connect to a local/host postgres database

From Dev

How to pause a docker container then reboot host system and unpause container?

From Dev

Link docker container with host

From Java

How to get the IP address of the docker host from inside a docker container

From Dev

Docker, how to remote ssh from command line host to a docker container?

From Dev

How to route to host in docker container during 'docker build'

From Dev

How to connect with JMX from host to Docker container in Docker machine?

From Dev

How to reach a docker container from a device that is in the same network as the docker host?

From Dev

How put Session with different database in laravel?

From Dev

Docker Container management in production environment

From Java

How to start a stopped Docker container with a different command?

From Dev

How to mount Docker container volumes to different path?

Related Related

  1. 1

    How to put docker container for database on a different host in production?

  2. 2

    Access host database from a docker container

  3. 3

    Docker - Run Apache on host and container for different websites

  4. 4

    Docker container Network connection between different host

  5. 5

    SSH into a docker container from another container on a different host

  6. 6

    How does glibc within a Docker image survive different container host kernels?

  7. 7

    How to copy files from host to Docker container?

  8. 8

    How to access host port from docker container

  9. 9

    How to merge host folder with container folder in Docker?

  10. 10

    How to mount a directory in a Docker container to the host?

  11. 11

    How to expose port from host to container in Docker?

  12. 12

    How to edit Docker container files from the host?

  13. 13

    How to mount a directory in the docker container to the host?

  14. 14

    How to connect my host mysql in docker container?

  15. 15

    How to mount host codes to container in docker?

  16. 16

    How to map a virtual host to a container in docker?

  17. 17

    Deploy a docker container to production

  18. 18

    Allow docker container to connect to a local/host postgres database

  19. 19

    How to pause a docker container then reboot host system and unpause container?

  20. 20

    Link docker container with host

  21. 21

    How to get the IP address of the docker host from inside a docker container

  22. 22

    Docker, how to remote ssh from command line host to a docker container?

  23. 23

    How to route to host in docker container during 'docker build'

  24. 24

    How to connect with JMX from host to Docker container in Docker machine?

  25. 25

    How to reach a docker container from a device that is in the same network as the docker host?

  26. 26

    How put Session with different database in laravel?

  27. 27

    Docker Container management in production environment

  28. 28

    How to start a stopped Docker container with a different command?

  29. 29

    How to mount Docker container volumes to different path?

HotTag

Archive