Home > Software > How to Deploy Portainer with Docker Compose: A Step-by-Step Tutorial

How to Deploy Portainer with Docker Compose: A Step-by-Step Tutorial

Anastasios Antoniadis

Discover the straightforward steps to deploy Portainer using Docker Compose, unlocking powerful container management features.

Docker (1)

Portainer is an open-source tool designed to simplify container management through a web-based user interface. It provides an intuitive dashboard for handling Docker and Kubernetes environments. It allows users to manage containers, images, networks, and volumes easily. Deploying Portainer using Docker Compose is a streamlined process that enhances its manageability and scalability. This guide will walk you through the setup of Portainer using Docker Compose, making it easy to get started with container management.


Before you start, ensure you have the following:

  • Docker installed on your system.
  • Docker Compose installed on your system.
  • Basic understanding of Docker concepts.

Step 1: Create a Docker Compose File

First, create a directory dedicated to your Portainer setup. This directory will contain your Docker Compose file (docker-compose.yml) and any additional configuration files.

mkdir portainer-docker && cd portainer-docker

Next, create the docker-compose.yml file:

touch docker-compose.yml

Open this file in a text editor and input the following configuration:

version: '3.7'

    image: portainer/portainer-ce:latest
    container_name: portainer
    restart: always
      - "9000:9000"
      - "8000:8000"
      - '/var/run/docker.sock:/var/run/docker.sock'
      - 'portainer_data:/data'
    command: -H unix:///var/run/docker.sock


Configuration Explained:

  • image: Specifies the Portainer CE (Community Edition) image. Using latest ensures you get the most recent version.
  • container_name: Sets a custom name for the container.
  • restart: Configures the container to automatically restart unless it is explicitly stopped.
  • ports: Exposes Portainer’s web interface (9000) and the edge agent port (8000) to the host, making Portainer accessible via the web browser.
  • volumes: Mounts the Docker socket as a volume, allowing Portainer to interact with the Docker daemon and manage containers. Additionally, it persists Portainer data across restarts and updates.
  • command: Specifies the Docker daemon as the endpoint for Portainer to manage.

Step 2: Launch Portainer

With your docker-compose.yml file ready, launch Portainer by running the following command in the directory containing your Docker Compose file:

docker compose up -d

This command starts Portainer in detached mode, running in the background.

Step 3: Access Portainer

After a few moments, Portainer will be up and running. You can access the Portainer web interface by navigating to http://your-server-ip:9000/ or http://localhost:9000/ in a web browser.

The first time you access Portainer, you’ll be prompted to create an admin user. After setting up your user, select “Docker” as the environment you wish to manage, and you’ll be directed to the Portainer dashboard.

Step 4: Managing Docker with Portainer

From the Portainer dashboard, you can now manage your Docker environment. Portainer provides functionalities to manage:

  • Containers: Start, stop, inspect, and remove containers.
  • Images: Pull, inspect, and remove images.
  • Networks: Create, inspect, and remove networks.
  • Volumes: Create, inspect, and remove volumes.
  • And more: Including managing Docker stacks and services.


Deploying Portainer with Docker Compose offers a straightforward and efficient method for managing Docker environments. By following the steps outlined in this guide, you can have a powerful container management tool running on your system, ready to simplify the complexities of Docker. Whether you’re managing a single host or multiple Docker environments, Portainer provides the necessary tools to ensure a smooth and intuitive management experience.

Anastasios Antoniadis
Follow me
0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x