What you need in order to get this to work successfully.
- Docker
- Docker Compose
Step 1:
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.
touch docker-compose.yaml
Step 2:
Open the docker-compose.yaml file using a text editor of your choice.
Step 3:
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:
Step 4:
Go back to the Terminal or Command Prompt shell that you opened earlier, and enter the command below.
docker-compose up
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.
Step 5:
Navigate to http://localhost:8080
on your browser, and this is the page you should expect to see.
Links:
Visit this GitHub repository, it has everything you need.
Top comments (3)
Here is my extension on your article - dev.to/vishalraj82/using-https-in-...
Wow that's amazing!
I love it.
Than you George.