13.3 C
Mel Khamlichi
Founder of Osradar, from Amsterdam Netherlands

Install latest wordpress in Docker

Docker is the future, its  introduced everywhere and you are able to deploy quickly  many containers applications in few minutes. i will show in this article the best way to install  fully wordpress in few minutes . please follow the instructions bellow.

To install the basic Docker please follow this article:

How to install Docker 

Now lets deploy the first application, How to deploy wordpress in Docker.

1-What we need

WordPress needs a LAMP stack to run. In this process, we are splitting that LAMP stack into two containers: one that runs the database (MySQL or MariaDB), and one that runs the webserver (PHP with Apache or PHP with Nginx).

Paste the YAML configuration  like this:

vi Install-wordpress.yaml

add the following :

version: '3.1'


image: wordpress
restart: always
- 8080:80

image: mysql:8
command: '--default-authentication-plugin=mysql_native_password'
# common options
restart: always

save and exit

docker-compose up will  build the images/containers for you and will bring everything up in seconds.

2-Install Docker-composer

Docker-composer orchestrator dont exist on basic repo of Centos . to do this you need to add the epel repos

 yum install epel-release
yum install docker-compose


To user docker-compse orchestrator you have to use the created yaml configuration file.

Lets  start

[root@osradar ~]# docker-compose -f Install-wordpress.yaml up &
Pulling mysql (mysql:8)...
Trying to pull repository ...
8: Pulling from
6ae821421a7d: Pull complete
a9e976e3aa6d: Pull complete
e3735e44a020: Pull complete
bfd564e9483f: Pull complete
df705f26e488: Pull complete
0c5547f73d62: Pull complete
f437382cf8a1: Pull complete
b8e2d50f1513: Pull complete
e2e3c9928180: Pull complete
b60db6d282cd: Pull complete
1d32deab69c6: Pull complete
408a40cd2e9c: Pull complete
Digest: sha256:a571337738c9205427c80748e165eca88edc5a1157f8b8d545fa127fc3e29269
Status: Downloaded newer image for
Pulling wordpress (wordpress:latest)...
Trying to pull repository ...
latest: Pulling from

3-Start The Configuration

Check if the containers are Up

[root@osradar ~]# docker container ps -a
908afa6b30e5 wordpress "docker-entrypoint..." 55 minutes ago Up 41 minutes>80/tcp root_wordpress_1
6fe7fb727fc8 mysql:8 "docker-entrypoint..." 55 minutes ago Up 41 minutes 3306/tcp, 33060/tcp root_mysql_1
[root@osradar ~]#

lunch  the browser  to  IP:8080 to  go a head   for  the  installation :

How to Access The WordPress  Files  in Docker

docker exec -it Container-ID  “/bin/bash”

How to Edit WordPress files in Docker

Docker containers are debian based  , you can use command apt or apt-get to   install packages

apt-get  update &  apt-get  install  vim nano

How to access mysql Container and check the database

apt-get  update &  apt-get  mysql-client

Connect to the database using  user root  , password is example

root@6fe7fb727fc8:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 8.0.15 MySQL Community Server - GPL

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
| Database |
| information_schema |
| mysql |
| performance_schema |
| sys |
| wordpress |
5 rows in set (0.00 sec)

Notice :  To detach the tty without exiting the shell, use the escape sequence Ctrl+p + Ctrl+q

- Advertisement -


Please enter your comment!
Please enter your name here

Donate to Osradar

Latest article