- Docker Compose
This first thing that you need to do is to create a project folder to work in, and inside the project folder you create Docker Compose file.
Open a Terminal or Command Prompt inside the project directory and run the command below.
Open the docker-compose.yaml file using a text editor of your choice.
Write the code below inside the docker-compose.yaml file and save.
version: '3.8' services: wordpress: image: wordpress restart: always ports: - '8080:80' environment: WORDPRESS_DB_HOST: db WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress WORDPRESS_DB_NAME: wordpress volumes: - wordpress:/var/www/html db: image: mysql:5.7 restart: always environment: MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress MYSQL_RANDOM_ROOT_PASSWORD: '1' volumes: - db:/var/lib/mysql volumes: wordpress: db:
Go back to the Terminal or Command Prompt shell that you opened earlier, and enter the command below.
Docker Compose shall execute the script and install the WordPress and MySQL images from docker hub.
It will then go ahead and Spin up two containers, one for each image.
Wait for about 1 minutes after docker-compose shows done for both containers before you can load WordPress on your browser.
http://localhost:8080 on your browser, and this is the page you should expect to see.
Visit this GitHub repository, it has everything you need.