Docker Community Forums

Share and learn in the Docker community.

Try to run wordpress on my ubuntu 20.04 server with docker


I want to install wordpress on my ubuntu 20.04 server with following commands by hand:

download nginx
docker image pull nginx

create containter
docker container run -d --name nginx-test -p 8080:80 nginx

Download image mysql
docker image pull mysql:5.7

Save database outside of the container
docker volume create mysql_data

Create network
docker network create wordpress

Create a Docker container for MYSQL
docker container run -d --name mysql -e MYSQL_ROOT_PASSWORD=wordpress -e MYSQL_DATABASE=wordpress -e MYSQL_USER=wordpress -e MYSQL_PASSWORD=wordpress --network wordpress -v mysql_data:/var/lib/mysql mysql:5.7

Check whether the database is running
docker container logs mysql

Download Wordpress Image
docker image pull wordpress

Create WordPress container
docker container run -v ~/wordpress:/var/www -d -e WORDEPRESS_DB_HOST=mysql:3306 -e WORDPRESS_DB_USER=wordpress -e WORDPRESS_DB_PASSWORD=wordpress -e WORDPRESS_DB_NAME=wordpress --link mysql:mysql --network wordpress -p 80:80 wordpress:latest

With the last command -v ~/wordpress:/var/www i want to make directory where the wordpress should be installed.

now when I call the domain I get the following error message:

Error establishing a database connection

And the next thing is that in /home /user/wordpress there is an html folder but no wordpress files.

Is there anyone who can give me some hint´s. I Try to understand but i think that docker is not as easys than some tells.

Thanks and Regards