I follow How to install WordPress in Docker Tutorial and found it has error in its docker-compose.yml file. Besides, it didn’t tell how to access phpMyAdmin and WordPress.
I am completely newbie on Docker so it took me time to really understand.
For that reason, I copy the tutorial and improve and simplify it. So it is easier for newcomer to Docker.
How To Install WordPress in Docker Using Docker Compose?
Create a folder for your project
1 |
mkdir dockerwordpress |
Create a docker-compose.yml file inside your folder
1 |
touch docker-compose.yml |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
Copy this Configuration to Your docker-compose.ymlversion: '3.9' services: mysql: image: mysql:8.0 volumes: - mysql_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress phpmyadmin: image: phpmyadmin/phpmyadmin depends_on: - mysql environment: PMA_HOST: mysql PMA_PORT: 3306 PMA_ARBITRARY: 1 restart: always ports: - 8183:80 wordpress: depends_on: - mysql image: wordpress:latest ports: - "8020:80" restart: always environment: WORDPRESS_DB_HOST: mysql:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress WORDPRESS_DB_NAME: wordpress volumes: - ./wordpress:/var/www/html volumes: mysql_data: {} |
Run The Docker WordPress Installation
Run Docker Compose Command Same Location as Your docker-compose.yml
1 |
docker-compose up -d |
Access WordPress
1 |
http://localhost:8020/ |
Run the usual WordPress Installation
Database Configuration:
Database name: wordpress
Username: wordpress
Password: wordpress
Testing Your WordPress Installation in Docker
Login using username and passoword, you have created. Then insert a post.
Check at phpMyAdmin
1 |
http://localhost:8183/ |
Server: <leave it empty>
Username: WordPress
Password: WordPress
Check Inserted Data
Last Note
With this docker-compose configuration you can’t access to your local file system. So this another thing I need to find the solution.