How to Install Portainer with Docker Compose on Ubuntu 24.04
Portainer is a popular tool for managing Docker containers through an easy-to-use web interface. It simplifies container management, making it accessible even to those new to Docker. In this guide, we will walk you through the steps to install Portainer using Docker Compose on Ubuntu 24.04.
Prerequisites
Before we start, ensure you have the following:
- An Ubuntu 24.04 server with a non-root user and sudo privileges.
- Docker and Docker Compose installed on your system.
Step 1: Update Your System
First, update your system to ensure all software packages are up to date. Open your terminal and run the following commands:
sudo apt update
sudo apt upgrade -y
These commands will update the package lists and upgrade the installed packages to the latest versions.
Step 2: Create a Docker Compose File for Portainer
Now that Docker and Docker Compose are installed, we can create a Docker Compose file for Portainer.
- Create a directory for Portainer:
mkdir ~/portainer
cd ~/portainer
2. Create the Docker Compose file:
Create a file named docker-compose.yml
:
nano docker-compose.yml
Add the following content to the file:
version: '3.8'
services:
portainer:
image: portainer/portainer-ce:latest
container_name: portainer
restart: unless-stopped
security_opt:
- no-new-privileges:true
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./portainer-data:/data
ports:
- 9000:9000
- This configuration defines the Portainer service, maps the necessary ports, and mounts the Docker socket.
- Save and close the file:Press
CTRL + X
, thenY
, and finallyEnter
to save the file and exit the editor.
Step 3: Deploy Portainer with Docker Compose
With your Docker Compose file ready, it’s time to deploy Portainer.
- Start the Portainer container:Run the following command in your terminal:
sudo docker-compose up -d
The -d
flag tells Docker Compose to run the containers in the background (detached mode).
Verify that Portainer is running:
You can check if the Portainer container is running with this command:
sudo docker ps
- You should see the
portainer/portainer-ce
container listed and running.
Step 6: Access the Portainer Web Interface
Now that Portainer is running, you can access its web interface.
- Open your web browser:Navigate to
https://your_server_ip:
9000.
Conclusion
Installing Portainer using Docker Compose on Ubuntu 24.04 is straightforward and highly beneficial. This setup allows you to manage your Docker environment easily through a powerful web interface. By following this guide, you now have a secure and functional Portainer installation ready to use. Regularly update your Docker and Portainer instances to ensure a secure and smooth operation.
Enjoy managing your Docker containers with Portainer!
Thank you for reading the article! If you found the information useful, you can donate using the buttons below:
Donate ☕️ with PayPalDonate 💳 with Revolut