Deploy wordpress with Docker compose - Linux Guru

image source medium

How to use Docker compose.

If you are using docker for your application and you are using more than one container for your app, then you have to use docker compose for app and it's too time consuming, example: web server with database will run from same file (WordPress,apache OR mysql). Docker compose allow you to use YAML file to run deploy multi container apps. We can configure multiple container we want. In the docker file it describe how app will build, connect and where data stored.
To run docker compose, You have to install docker and docker compose in your PC.
To install docker click here.
  • Install docker compose.
Download latest version of docker compose.
$ curl -L`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
  • Give the permission to the binary.
$ chmod +x /usr/local/bin/docker-compose
  • Now we will install wordpress site along with mysql using docker compose. let's create docker compose file.
$ vim docker-compose.yaml
version: '3'



     image: mysql:5.7


       - db_data:/var/lib/mysql1

     restart: always


       MYSQL_ROOT_PASSWORD: yourRootpassword

       MYSQL_DATABASE: wordpress

       MYSQL_USER: wordpress

       MYSQL_PASSWORD: yourpassword



       - database

     image: wordpress:latest


       - "80:80"

     restart: always


       WORDPRESS_DB_HOST: db:3306

       WORDPRESS_DB_USER: wordpress

       WORDPRESS_DB_PASSWORD: yourpassword


Save the file and run the docker compose from same directory.This file will build database and WordPress containers. it will run docker with -d flag with detached mode.
  • Run docker compose.
$ docker-compose up -d
  • You can check the docker status of the file.
$ docker ps 

  • To remove the docker composer.
$ docker-compose down
Check from browser with localhost and configure with your settings.

Vishal Vyas [Linux Guru]

Welcome to Linux Guru! Hello, friends. My name is Vishal Vyas, and I am a DevOps engineer with expertise in Linux and Cloud Computing. I am also a Certified Kubernetes Administrator with over 12 years of experience in the IT field, working with various technologies. Through this blog, I aim to share my technical knowledge on Linux, AWS, DevOps, and web technologies. I will be posting about what I have learned from the latest web technologies and similar topics.

Post a Comment

If you have any doubts, Please let me know

Previous Post Next Post