As organizations strive for efficiency and scalability, Docker has emerged as a powerful tool for deploying applications in isolated environments. Ubuntu 24.04, with its stability and robustness, is an excellent foundation for running containerized applications. In this guide, we walk you through installing Docker and Docker Compose on Ubuntu 24.04, and show you how to set up popular applications such as WordPress, Redmine, Odoo, Dolibarr, and ERPNext using Docker Compose.
Installing Docker on Ubuntu 24.04
Step 1: Update the Package Index
The first step in containerizing your applications is to install Docker. Begin by updating your package index using the command:
sudo apt update
Step 2: Install Required Packages
Then, install the necessary prerequisites for Docker by running:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Step 3: Add Docker’s Official GPG Key
Next, add Docker’s official GPG key to ensure package authenticity and set up the Docker repository:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Step 4: Set Up Docker Repository
Add Docker’s official APT repository to your system.
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Step 5: Install Docker
After this, update your package index again and install Docker:
sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io
Step 6: Verify Docker Installation
To confirm Docker is installed and working correctly:
sudo docker --version
Step 7: Manage Docker as a Non-root User
If you’d like to avoid using sudo
with every Docker command, add your user to the docker
group:
sudo usermod -aG docker $USER
Log out and log back in for the changes to take effect.
Installing Docker Compose
Step 1: Download Docker Compose Binary
Find the latest release of Docker Compose from the GitHub releases page. Then download it using the following command:
sudo curl -L "https://github.com/docker/compose/releases/download/v2.20.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Step 2: Set Permissions
Make the Docker Compose binary executable.
sudo chmod +x /usr/local/bin/docker-compose
Step 3: Verify Docker Compose Installation
Check the installed version:
docker-compose --version
Setting Up Applications Using Docker Compose
You will create separate directories for each application and place a docker-compose.yml
file in each. Below is how to set up WordPress, Redmine, Odoo, Dolibarr, and ERPNext with Docker Compose.
1. WordPress
You can easily install WordPress using Docker Compose by following these steps. This setup will include both WordPress and MySQL containers to create a fully functional WordPress environment.
Step 1: Create a Directory
Create a new directory for your WordPress project and navigate to it:
mkdir ~/wordpress && cd ~/wordpress
Then, create a docker-compose.yml
file in this directory:
nano docker-compose.yml
Step 2: Define services in docker-compose.yml
Add the following content to the docker-compose.yml
file:
version: '3.8' services: wordpress: image: wordpress:latest ports: - "8080:80" environment: WORDPRESS_DB_HOST: db WORDPRESS_DB_USER: user WORDPRESS_DB_PASSWORD: password WORDPRESS_DB_NAME: wordpress restart: always volumes: - wordpress_data:/var/www/html db: image: mysql:5.7 environment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: wordpress MYSQL_USER: user MYSQL_PASSWORD: password restart: always volumes: - db_data:/var/lib/mysql volumes: wordpress_data: db_data:
Step 3: Run Docker Compose
After saving the docker-compose.yml
file, run the following command to start the WordPress and MySQL containers:
docker-compose up -d
The -d
flag runs the containers in detached mode (in the background).
Step 4: Access WordPress
Once the containers are running, open your web browser and go to:
http://localhost:8080
You will see the WordPress setup screen. Follow the instructions to complete the installation, setting your site title, admin username, password, and email.
Step 5: Stop the services
To stop the WordPress and MySQL containers, run:
docker-compose down
This will stop and remove the containers, but the data will persist in the volumes you created. You can bring them back up later using docker-compose up
.
2. Dolibarr
You can easily install WordPress using Docker Compose by following these steps. This setup will include both WordPress and MySQL containers to create a fully functional WordPress environment.
Step 1: Create a Directory
Create a new directory for your WordPress project and navigate to it:
mkdir ~/dolibarr && cd ~/dolibarr
Then, create a docker-compose.yml
file in this directory:
nano docker-compose.yml
Step 2: Define services in docker-compose.yml
Add the following content to the docker-compose.yml
file:
version: '3.3' services: dolibarr: image: 'tuxgasy/dolibarr:latest' container_name: dolibarr ports: - '8080:80' # Exposes Dolibarr on port 8080 volumes: - dolibarr_data:/var/www/html/documents environment: - DOLI_DB_HOST=db - DOLI_DB_NAME=dolibarr - DOLI_DB_USER=dolibarruser - DOLI_DB_PASSWORD=dolibarrpassword depends_on: - db db: image: 'mysql:5.7' container_name: dolibarr_db environment: - MYSQL_ROOT_PASSWORD=rootpassword - MYSQL_DATABASE=dolibarr - MYSQL_USER=dolibarruser - MYSQL_PASSWORD=dolibarrpassword volumes: - db_data:/var/lib/mysql volumes: dolibarr_data: db_data:
Step 3: Run Docker Compose
After saving the docker-compose.yml
file, run the following command to start the WordPress and MySQL containers:
docker-compose up -d
The -d
flag runs the containers in detached mode (in the background).
Step 4: Access Dolibarr
Once the containers are running, open your web browser and go to:
http://localhost:8080
You will see the Dolibarr login screen. Default admin username / password is admin/admin
Step 5: Stop the services
To stop the WordPress and MySQL containers, run:
docker-compose down
This will stop and remove the containers, but the data will persist in the volumes you created. You can bring them back up later using docker-compose up
.
Managing Docker Containers
To manage your Docker containers and applications through a graphical user interface (GUI), you can use several tools. These tools provide an intuitive way to control, monitor, and manage your Docker environments. Here are some popular options:
1. Portainer
Portainer is a widely used open-source tool for managing Docker environments. It offers a web-based interface for managing Docker containers, images, networks, and volumes.
Installation and Setup
- Install Portainer:
Run the following command to deploy Portainer using Docker:docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
- Access Portainer:Open your web browser and go to
http://localhost:9000
. The first time you access Portainer, you’ll need to create an admin user account. - Use Portainer:Once logged in, you can use Portainer to manage your Docker containers, images, networks, and volumes. You can start, stop, restart containers, view logs, and more.