Install WordPress with Docker
Table of Contents
Installing WordPress on a server is not especially hard, but you can simplify it using Docker containers.
- Install Docker if it’s not already installed (Install Docker).
- Create a network (replace NETWORK_NAME):
docker network create NETWORK_NAME
- Run MySQL container. Replace
DB_HOSTwith a name for the container,NETWORK_NAMEwith your new network name,DB_NAMEwith a name for the database,DB_USERwith a name for the database user andDB_PASSWORDwith a password for the database:
docker run --name DB_HOST -d --network NETWORK_NAME -e MYSQL_DATABASE=DB_NAME -e MYSQL_USER=DB_USER -e MYSQL_PASSWORD=DB_PASSWORD -e MYSQL_RANDOM_ROOT_PASSWORD=yes mysql:latest
- Run WordPress container (wait 10 seconds for MySQL container to set up). Replace
WP_CONTAINERwith a name for the container,NETWORK_NAMEfor network name,DB_HOSTwith the MySQL container name,DB_USERwith the database user,DB_PASSWORDwith the database password andDB_NAMEwith database name:
docker run --name WP_CONTAINER -d --network NETWORK_NAME -p 8080:80 -e WORDPRESS_DB_HOST=DB_HOST -e WORDPRESS_DB_USER=DB_USER -e WORDPRESS_DB_PASSWORD=DB_PASSWORD -e WORDPRESS_DB_NAME=DB_NAME wordpress:latest
- Now you can access your newly created website typing your VPS public IP and port 8080 in your browser (check your VPS provider’s firewall to open port 8080):
http://<SERVER-PUBLIC-IP>:8080.
Don’t have a server yet? Here are some free VPS options and free trials you can use to follow this tutorial.
If you have any suggestion, feel free to contact me via social media or email.
Latest tutorials and articles:
Featured content: