Skip to main content

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
intermediate
cloud
Linux
60 minutes
8 steps
Prerequisites
  • 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.

Get Started with DigitalOcean

Disclosure: This is an affiliate link. We may earn a commission at no extra cost to you.

Learning Objectives
  • 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
Technologies Used
Ubuntu 24.04
Docker
Docker Compose
Nginx
WordPress
MySQL
Exercise Steps
1

Install Docker Engine

Current

Install Docker from the official Docker repository. The Ubuntu default repository often has an older version, so we add Docker's own apt source.

2

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.

3

Run and Manage Containers

Practice the basic Docker commands by running an Nginx container, checking logs, and cleaning up.

4

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.

5

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.

6

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.

7

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.

8

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?