Create multiple containers with a shared database

I would like to create multiple Docker containers, but they use the same database. In the best case this should happen in one step e.g. via docker-compose. Is this possible? The file system of the containers should of course be separate.

Of course this is possible. It seems Orientation and setup | Docker Documentation may be a good start, especially Part 7, Multi-container apps and Part 8, Use Docker Compose. (But: I’d start from the beginning.)

Using the example in that documentation, both WordPress containers could refer to mysql as the database’s host name.

1 Like