Docker Community Forums

Share and learn in the Docker community.

How to install wordpress by docker?

I need deploy Wordpress in my new VPS, but I found that not work, and I testing again by docker official install guide, that should same status, I need your kindly help for the issue, appreciated!

Official install guide:

what is the issue? did you expose wordpress’s port? the official docker compose should work.

Hi, Junius

As I understand, port 80 should default expose and not need extra config, please let me know if I am wrong.
How do we verify whether wordpress work normal? As I said, no any respond by “curl”.


Could you please post details how you run wordpress?

wordpress container exposes port 80. but you need to publish it to a host port. ports: - "8000:80" in the compose file, or -p 8080:80 in docker run.

Hi, Junius

Follow detail information that I follow official docker install guide, you can check that:

[root@frank-vps my_wordpress]# more docker-compose.yml
version: '3'

     image: mysql:5.7
       - db_data:/var/lib/mysql
     restart: always
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

       - db
     image: wordpress:latest
       - "8000:80"
     restart: always
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
    [root@frank-vps my_wordpress]#
    [root@frank-vps my_wordpress]# docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
    91f3d090a116        wordpress:latest    "docker-entrypoint..."   26 hours ago        Up 26 hours>80/tcp   mywordpress_wordpress_1
    b116d0cf4c67        mysql:5.7           "docker-entrypoint..."   26 hours ago        Up 26 hours         3306/tcp               mywordpress_db_1
[root@frank-vps my_wordpress]# curl localhost:8000
[root@frank-vps my_wordpress]#
[root@frank-vps my_wordpress]#

Could you please try to access via browser? The browser to http://localhost:8000 will show the page. Not sure about curl.

Hi, Junius

Appreciated your kindlly help!
If I do “docker run xxxx” that should not work for me, that maybe command not correct.
Then I tried compose of docker, curl no any output, but not check web, after checked, as you said that should work. So curl no any output should normal.

When I test the compose of docker for Wordpress, share follow tips and experiences:

  1. If you want to mapping the mysql and wordpress, can add follow config in compose

    - ./mysql_data:/var/lib/mysql

    - ./wordpress_data:/var/www/html

  2. When you change “docker-compose.yml”, please not only use “docker-compose down” that will not delete all config/file, suggest you do “docker-compose down --volumes” that as install guide.

  3. If you change database name, please add “WORDPRESS_DB_NAME: xxx” in environment part of Wordpress(docker-compose.yml), that should no this config in official install guide. So wordpress default connect database name is “wordpress”.

  4. If you want to debug wordpress/mysql and check log, you can not add “-d”, use this “docker-compose up”

  5. In order to restore mysql database, you can install phpmyadmin by docker, then add follow config to “docker-compose.yml”, and follow guide by “

        - db
      image: phpmyadmin/phpmyadmin
        - "8080:80"
      restart: always
        PMA_HOST: db
        PMA_USER: xxxx
        PMA_PASSWORD: xxxx

Thanks again!

The problem is that these instructions say nothing about themes - where to put them and how to ensure edits show up; getting the database is only half of the story


If you want to debug wordpress/mysql and check log, you can not add “-d”, use this “docker-compose up”

That’s not entirely correct, Yong. You can connect to a docker container (started with “-d”) using docker attach [CONTAINER NAME] where [CONTAINER NAME] is the name of your container.