Skip to content

Categories

  • Artificial Intelligence 233
  • Technology 198
  • Tools 113
  • Architecture 91
  • Methodologies 76
  • Software Development 54
  • Industry 4.0 25
  • User Experience 21
  • How to Install 20
  • Startup 9

Hands-on Lab

Install Portainer with Docker Compose v2

July 12, 2026 1 min 46
0 / 4
Cheat sheet
Your teacher The lab instructor

Found it useful? Don't miss the next lab

Newsletter · jacar.es

Subscribe to the newsletter

Subscribed! Check your inbox.

No spam. Unsubscribe anytime.

By subscribing you accept our privacy policy.

0:00 / 0:00
Steps

Create a dedicated working directory (~/docker/portainer) to hold the stack's compose.yaml. Keeping each stack in its own folder makes it easy to version, back up and manage with `docker compose` from there.

mkdir -p ~/docker/portainer

Write compose.yaml following the current Compose Specification: no `version:` key, image pinned to `portainer-ce:2.40.0` (never `:latest`), ports 9443 (HTTPS UI) and 8000 (Edge Agent tunnel), the Docker socket mounted read-only (`:ro`) since Portainer drives everything over the API, and a named `portainer_data` volume so the data survives upgrades.

cat > ~/docker/portainer/compose.yaml <<'YAML'
services:
  portainer:
    image: portainer/portainer-ce:2.40.0
    container_name: portainer
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    ports:
      - "9443:9443"
      - "8000:8000"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - portainer_data:/data
volumes:
  portainer_data:
YAML

Validate the syntax before starting anything: `docker compose config` parses the file and fails on a bad indent or an invalid key. If it prints `compose.yaml OK`, you're good.

docker compose -f ~/docker/portainer/compose.yaml config -q && echo 'compose.yaml OK'

Bring the stack up in the background (`-d`). Docker pulls the image if missing, creates the `portainer_data` volume and starts the `portainer` container with `restart: unless-stopped`, which brings it back after a host reboot.

cd ~/docker/portainer && docker compose up -d

Check the service is `running` and listening on `0.0.0.0:9443` before opening the browser. `docker compose ps` reports the status of the stack defined in this directory.

cd ~/docker/portainer && docker compose ps

Open https://<IP>:9443 (self-signed cert: accept the warning), create the admin user with a 12+ character password —the form expires after 5 minutes— and log in: the local Docker environment is right there and the install works.

46 views Watch on YouTube

Was this lab useful? Rate it:

Click to rate this post!
[Total: 0 Average: 0]

Learn how to install Portainer with Docker Compose on Linux: a compose.yaml with a pinned image, a persistent volume and the UI on port 9443, step by step.

Cheat sheet

  1. mkdir -p ~/docker/portainer
  2. cat > ~/docker/portainer/compose.yaml <<'YAML'
    services:
      portainer:
        image: portainer/portainer-ce:2.40.0
        container_name: portainer
        restart: unless-stopped
        security_opt:
          - no-new-privileges:true
        ports:
          - "9443:9443"
          - "8000:8000"
        volumes:
          - /etc/localtime:/etc/localtime:ro
          - /var/run/docker.sock:/var/run/docker.sock:ro
          - portainer_data:/data
    volumes:
      portainer_data:
    YAML
  3. cd ~/docker/portainer && docker compose up -d
Javier Cañete Arroyo — JACAR La marca JACAR toma las dos primeras letras de cada parte del nombre: JAvier, CAñete, ARroyo. CEO · FUNDADOR JAvierCAñeteARroyo JACAR JAvier · CAñete · ARroyo

Production notes on technology, DevOps, and AI from Madrid.

Madrid, ES · ES / EN

LinkedIn RSS Jacar Systems

Explore

  • Learning paths
  • Artificial Intelligence 233
  • Technology 198
  • Tools 113
  • Architecture 91
  • Methodologies 76
  • Software Development 54

Latest

  • OpenRouter: A Gateway for AI Models 17 Jul 2026
  • browser-use: agents that browse the web 17 Jul 2026
  • Firecrawl: Web Data for Agents 17 Jul 2026
  • Composio: Tools and Integrations for Agents 17 Jul 2026

Connect

1198 posts published Search the site
Topics #llm #docker #agentes #self-hosting #neural-networks #deep-learning #observabilidad #rag #kubernetes #seguridad
© 2026 Jacar Systems S.L. · made with in Madrid Systems operational
Privacy Cookies RSS

We use first- and third-party cookies to analyze site traffic. You can accept them, reject them, or configure your choice. Learn more about cookies

Cookie preferences

  • Necessary Essential for the site to work. Always on.
  • Analytics Help us understand how the site is used (Google Analytics).
  • Marketing Ad personalization and campaigns.

More in our cookie policy and privacy policy.