Run a local WordPress installation via Docker

R

Requirements:

Open Terminal and enter the following command to set up the MYSQL container with the database.

docker run --name wordpressdb_docker -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=wordpress -d mysql:5.7

Note: “wordpressdb_docker” is the name of the image, “password” the password and “wordpress” the database name.

then go to the directory where you would like to have your WordPress-files with the cd command. e.g.

cd ~/Desktop/wordpress

after that you can pull the official Docker WordPress-Image:

docker pull wordpress

this will download all needed WordPress-files to the current directory (e.g. Desktop/wordpress)

after that you can run your wordpress-image, using the MYSQL container with the following command:

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

Note: “wordpresscontainer” is the name of the new docker image. “wordpressdb_docker” is the already created database-image.

Your WordPress-Installation is now ready to use. You can access through 127.0.0.1:8080 in your web-browser and set up the installation as usual.

You can stop running containers with the following command

docker stop container-name

To (re-)start your docker images you can execute the following commands:

docker start wordpressdb_docker
docker start wordpresscontainer

Note: The database-container has to be started up first!

If you need to remove a container you can do it with the following command:

docker rm -f container-name

 

 

Recent Posts

Categories

Archives