Install WordPress with Docker
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_HOST
with a name for the container,NETWORK_NAME
with your new network name,DB_NAME
with a name for the database,DB_USER
with a name for the database user andDB_PASSWORD
with 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_CONTAINER
with a name for the container,NETWORK_NAME
for network name,DB_HOST
with the MySQL container name,DB_USER
with the database user,DB_PASSWORD
with the database password andDB_NAME
with 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
.
If you have any suggestion, feel free to contact me via social media or email.
Latest tutorials and articles:
Featured content: