Docker Community Forums

Share and learn in the Docker community.

How to install wordpress by docker?

docker

(Frank1983) #1

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:


(Junius) #2

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


(Frank1983) #3

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”.

Thanks
Yong


(Junius) #4

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.


(Frank1983) #5

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'

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

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
volumes:
    db_data:
    [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         0.0.0.0:8000->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]#

(Junius) #6

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


(Frank1983) #7

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

    volumes:
    - ./mysql_data:/var/lib/mysql

    volumes:
    - ./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 “https://hub.docker.com/r/phpmyadmin/phpmyadmin/

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

Thanks again!
Yong


(Hotbelgo) #8

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


(Vikramdurai) #9

@frank1983

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.