Running applications with Docker Compose
Docker Compose (http://docs.docker.com/compose/) is the native Docker tool that runs interdependent containers that make up an application. We define a multicontainer application in a single file and feed it to Docker Compose, which sets up the application. In this recipe, we'll once again use WordPress as a sample application to run.
Getting ready
To install Docker Compose, run the following command:
$ sudo pip install docker-compose
How to do it
Follow these steps:
- Create a directory for the application, and within it, create
docker-compose.yml
to define the app:
$ cd wordpress_compose/ $ cat docker-compose.yml version: '3.1' services: wordpress: image: wordpress restart: always ports: - 8080:80 environment: WORDPRESS_DB_PASSWORD: example mysql: image: mysql:5.7 restart: always environment: MYSQL_ROOT_PASSWORD: example
- We took the preceding example from the official WordPress Docker repository on Docker...