How to deploy a WordPress Docker container using docker-compose

These are the steps to setup the current website in a Docker container:



wget -O- https://github.com/docker/compose/releases/download/1.2.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

mkdir wordpress
cd wordpress

Then create a file fig.yml which contains:


db:
  image: mysql:5.5
  environment:
    MYSQL_ROOT_PASSWORD: "A VERY STRONG PASSWORD"
web:
  image: wordpress:latest
  ports:
    - "80:80"
  links:
    - db:mysql
EOF

This description takes advantage of a Docker feature to bind together two or more containers: Docker links. We use it to make the WordPress container depends on another container with MySQL 5.5.

The docker-compose up command will read fig.yml, download the needed data and deploy the two containers.


/usr/local/bin/docker-compose up

Et voilà, the port 80 of the host which runs the container will be forwarded to the port 80 of the WordPress container.

3 thoughts on “How to deploy a WordPress Docker container using docker-compose”

Leave a Reply

Your email address will not be published. Required fields are marked *