5

I'm trying to run wordpress inside docker.

I've been following this tutorial : https://www.sitepoint.com/how-to-use-the-official-docker-wordpress-image/

But when I run this command :

docker run -e WORDPRESS_DB_PASSWORD=xxxxxx -d --name wordpress --link wordpressdb:mysql -p 127.0.0.1:8080:80 -v "$PWD/":/var/www/html wordpress

The container crashes, and in the logs I can see things like :

tar: ./wp-admin: Cannot mkdir: Permission denied
2

Try to run such command as root or grant user and group rights to the folder with chown.

That's only what comes to my mind for now.

  • I'm running it as root yes. And used chmod 777 on the folder I wanted to link – Loïc Aug 21 '17 at 2:45
2

Hm, i'll answer myself here I guess.

The problem was, I had "broken" volumes.

So, I've made a little script to "reset" docker and install wordpress. Careful it removes everything.

#!/bin/bash

# remove images
docker rmi $(docker images -q)  
# remove containers
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)    
# remove volumes
docker volume rm $(docker volume ls -q)

echo "Type mysql root password : "
read mspass

docker run --name wordpressdb -e MYSQL_ROOT_PASSWORD=$mspass -e MYSQL_DATABASE=wordpress -d mysql:5.7

docker run -e WORDPRESS_DB_PASSWORD=$mspass --name wordpress --link wordpressdb:mysql -p 127.0.0.2:8080:80 -v "$PWD/":/var/www/html -d wordpress
  • What do you mean with broken volumes? – RuBiCK Aug 27 '17 at 14:59
  • I don't really know, it's just when I removed them everything worked fine – Loïc Aug 27 '17 at 18:25
1

In order to check it if that directory exists and its permissions, execute ls -la $PWD

PS:This should be a comment but I do not have enough rep Are you sure you are in the right directory?

  • Have you been tried to use absolute path? – RuBiCK Aug 21 '17 at 11:14
1

Perhaps information like 1) the docker host OS details (RHEL, Centos, Ubuntu, etc) 2) the mounted directory permission (ls -al) would help to debug this issue...

This could be an SELinux issue as well, so disable SELinux and try

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.