Code in this video_Install Docker & Portainer on VPS Linux Ubuntu/Debian

✳️ Replace the highlighted information with your own

version: '3.8'

services:
portainer:
image: portainer/portainer-ce:2.27.9
container_name: portainer
restart: always
ports:
- "9443:9443"
- "9000:9000"
command: --host unix:///var/run/docker.sock
user: "0:0"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
networks:
- docker_network

volumes:
portainer_data:

networks:
docker_network:
external: true

Note:

  • version: ‘3.8’ – Use Docker Compose version 3.8
  • image: portainer/portainer-ce:2.27.9 – Use Portainer CE image version 2.27.9
  • container_name: portainer – Name the container “portainer”
  • restart: always – Automatically restart the container if it crashes or after reboot
  • “9443:9443” – Expose HTTPS port
  • “9000:9000” – Expose HTTP port (default web UI)
  • command: –host unix:///var/run/docker.sock – Allow Portainer to communicate with Docker
  • user: “0:0” – Run as root
  • /var/run/docker.sock:/var/run/docker.sock – Mount Docker socket from the host
  • portainer_data:/data – Persist Portainer data in a named volume
  • docker_network – Connect to a custom Docker network
  • portainer_data: – Define a named volume for Portainer data
  • external: true – Use an existing Docker network (must be created beforehand)

Leave a Reply

Your email address will not be published. Required fields are marked *