# Wordpress Example in Docker compose fails

**URL:** <https://forums.docker.com/t/wordpress-example-in-docker-compose-fails/30438>\
**Category:** General\
**Created:** [March 29, 2017, 7:27pm UTC](https://forums.docker.com/t/wordpress-example-in-docker-compose-fails/30438 "2017-03-29T19:27:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rbrynaphis](https://avatars.discourse-cdn.com/v4/letter/r/49beb7/32.png) [@rbrynaphis](https://forums.docker.com/u/rbrynaphis)\
**Post date:** [March 29, 2017, 7:27pm UTC](https://forums.docker.com/t/wordpress-example-in-docker-compose-fails/30438/1 "2017-03-29T19:27:44Z")

</div>

I’m learning Docker and am to the point where I can start 1 container with no problems… so I thought I’de start working on something using 2 containers and I’m a little more familiar with. I am trying to step through the example at [https://docs.docker.com/compose/wordpress/](https://docs.docker.com/compose/wordpress/) (i copied it exactly) and can get the containers to build and start with no issue… .but something is amiss…

I get the following error when viewing the logs on the wordpress container.  
Warning: mysqli::mysqli(): (HY000/1045): Access denied for user ‘root’@‘172.18.0.3’ (using password: YES) in - on line 22

when I login to the console of the mysql db - it doesn’t like the password that is specified in the yml file (trying with mysql -u root -p) and it generates the error ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)

any tips? I’m going crazy trying to figure out why the example doesn’t work.

running on Ubuntu

---

<div class="post-metadata">

**Author:** ![mkorejo](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/mkorejo/32/15452_2.png) [@mkorejo](https://forums.docker.com/u/mkorejo)\
**Post date:** [March 30, 2017, 2:13am UTC](https://forums.docker.com/t/wordpress-example-in-docker-compose-fails/30438/2 "2017-03-30T02:13:35Z")

</div>

If you are using `docker-compose` still and the `docker-compose.yml` was copied _exactly_, then the MySQL root password should be `wordpress`. Looks like your WordPress container is attempting to login to MySQL as root which is okay and again expected if you are following the example exactly.

The command to login to MySQL from inside the container should be `mysql -u root -pwordpress`. This fails?

Also, try specifying an explicit tag for WordPress in `docker-compose.yml`, like `image: wordpress:php7.1`. Just checked and a tag with `-fpm` is latest, I recall this threw a wrench in things when I was playing with this a while back.

---

<div class="post-metadata">

**Author:** ![rbrynaphis](https://avatars.discourse-cdn.com/v4/letter/r/49beb7/32.png) [@rbrynaphis](https://forums.docker.com/u/rbrynaphis)\
**Post date:** [March 30, 2017, 1:47pm UTC](https://forums.docker.com/t/wordpress-example-in-docker-compose-fails/30438/3 "2017-03-30T13:47:57Z")

</div>

yup… copied the example _exactly_ issuing this from the mysql container cli and i get…

```
root@43a759f6ae7b:/# mysql -u root -pwordpress
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

```

The mysql environment variables are;  
environment:  
MYSQL\_ROOT\_PASSWORD: wordpress  
MYSQL\_DATABASE: wordpress  
MYSQL\_USER: wordpress  
MYSQL\_PASSWORD: wordpress

I just can’t explain why I can’t login to the mysql db - I’m going nuts here.

---

<div class="post-metadata">

**Author:** ![rbrynaphis](https://avatars.discourse-cdn.com/v4/letter/r/49beb7/32.png) [@rbrynaphis](https://forums.docker.com/u/rbrynaphis)\
**Post date:** [March 31, 2017, 2:45pm UTC](https://forums.docker.com/t/wordpress-example-in-docker-compose-fails/30438/4 "2017-03-31T14:45:18Z")

</div>

Solved the mystery (for anyone else that runs into it)

The example file has a volume defined;  
volumes:  
- db\_data:/var/lib/mysql

when you change that to something other than /var/lib/mysql it seems to work fine. I don’t understand enough yet to know why it does’t work with default path, but changing it to - db\_data:/var/lib/mysql2 allows it to work fine.

---

<div class="post-metadata">

**Author:** ![kauanslr](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/kauanslr/32/16977_2.png) [@kauanslr](https://forums.docker.com/u/kauanslr)\
**Post date:** [August 28, 2017, 4:40pm UTC](https://forums.docker.com/t/wordpress-example-in-docker-compose-fails/30438/5 "2017-08-28T16:40:05Z")

</div>

You’ve saved my life \<3

---

<div class="post-metadata">

**Author:** ![cegrif01](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@cegrif01](https://forums.docker.com/u/cegrif01)\
**Post date:** [November 20, 2018, 12:22am UTC](https://forums.docker.com/t/wordpress-example-in-docker-compose-fails/30438/6 "2018-11-20T00:22:15Z")

</div>

That really does work, but it’s bothering me. WHY does this work? Haha, oh well. Thank you [rbrynaphis](https://forums.docker.com/u/rbrynaphis), you saved me a lot of time!

---

<div class="post-metadata">

**Author:** ![djarrin](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/djarrin/32/22508_2.png) [@djarrin](https://forums.docker.com/u/djarrin)\
**Post date:** [January 24, 2019, 7:20pm UTC](https://forums.docker.com/t/wordpress-example-in-docker-compose-fails/30438/7 "2019-01-24T19:20:17Z")

</div>

May I suggest that if you have another docker instance set up to go to that db\_data then there will be some sort of conflict? Thats my best theory.

---

<div class="post-metadata">

**Author:** ![davidxyz](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@davidxyz](https://forums.docker.com/u/davidxyz)\
**Post date:** [May 2, 2020, 10:33pm UTC](https://forums.docker.com/t/wordpress-example-in-docker-compose-fails/30438/8 "2020-05-02T22:33:36Z")

</div>

Thank you , you also saved my life

---

<div class="post-metadata">

**Author:** ![royerreyesleon](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@royerreyesleon](https://forums.docker.com/u/royerreyesleon)\
**Post date:** [April 10, 2024, 5:11pm UTC](https://forums.docker.com/t/wordpress-example-in-docker-compose-fails/30438/9 "2024-04-10T17:11:09Z")

</div>

thank you very much, you saved me a lot of time
