Table of Contents

Installing WordPress on a server is not especially hard, but you can simplify it using Docker containers.

  1. Install Docker if it’s not already installed (Install Docker).
  2. Create a network (replace NETWORK_NAME):
docker network create NETWORK_NAME
  1. 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 and DB_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
  1. 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 and DB_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
  1. 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.