Running Docker Containers on Your Linux Server
Install Docker and Docker Compose on Ubuntu, run your first container, deploy a WordPress stack with docker-compose, and set up Nginx as a reverse proxy in front of your containers.
Need a server? Get $200 free credits on DigitalOcean- A running Ubuntu 24.04 server with sudo access
- Basic understanding of the Linux command line
- Familiarity with YAML syntax is helpful but not required
You need a running Linux server for this exercise. Any Ubuntu server works, but we recommend DigitalOcean for quick setup.
Get $200 in free credits to get started.
Disclosure: This is an affiliate link. We may earn a commission at no extra cost to you.
- Install Docker Engine and Docker Compose on Ubuntu 24.04
- Run and manage Docker containers from the command line
- Write a docker-compose.yml file for a multi-container application
- Use Docker volumes for persistent data
- Configure Nginx as a reverse proxy for Docker containers
Install Docker Engine
Install Docker from the official Docker repository. The Ubuntu default repository often has an older version, so we add Docker's own apt source.
Configure Docker and Verify the Installation
Add your user to the docker group so you do not need sudo for every docker command, then run a test container.
Run and Manage Containers
Practice the basic Docker commands by running an Nginx container, checking logs, and cleaning up.
Deploy WordPress with Docker Compose
Create a docker-compose.yml file that runs WordPress with a MySQL database. This is a realistic multi-container setup that you would actually use in production.
Start the WordPress Stack
Use docker compose to bring up the WordPress and MySQL containers. Docker will pull the images, create volumes, and start everything.
Manage the Docker Compose Stack
Learn the essential docker compose commands for day-to-day management: stopping, starting, viewing resource usage, and accessing container shells.
Set Up Nginx as a Reverse Proxy
Instead of exposing WordPress directly on port 8080, put Nginx in front of it as a reverse proxy. This lets you use your domain name, add SSL later, and serve multiple apps from one server.
Lock Down the Direct Docker Port
Now that Nginx proxies traffic to WordPress, stop exposing port 8080 to the public internet. Update docker-compose.yml to bind only to localhost.
Found an issue?