Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

https://www.portainer.io/installation/

Create Container:

Note: I got error on first docker run, but I just ran it again and it worked correctly

docker volume create portainer_data
docker run -d -p 9876:9000 --name=portainer -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
WD=/opt/portainer
mkdir -p $WD/{mnt,setup,data}
cd $WD/setup
cat << 'EOF' >docker-compose.yaml
version: '3.7'

services:
 portainer:
    container_name: portainer
    hostname: portainer
    image: portainer/portainer
    command: -H unix:///var/run/docker.sock
    ports:
      - '9876:9000'
    volumes:
      - type: bind
        source: /opt/portainer/data/
        target: /data
      - type: bind
        source: /var/run/docker.sock
        target: /var/run/docker.sock
    environment:
      - 'TZ=America/Whitehorse'
EOF
chmod +x docker-compose.yaml


Confirm:

domain:9876

SystemD Integration:

cat << 'EOL' >/lib/systemd/system/portainer.service
[Unit]
Description=Docker_Description
Requires=docker.service network-online.target

[Service]
Restart=on-abnormal
ExecStart=/usr/bin/docker start -a portainer
ExecStop=/usr/bin/docker stop -t 2 portainer

[Install]
WantedBy=multi-user.target
EOL
systemctl enable portainer
systemctl start portainer
systemctl status portainer
WD=/opt/portainer/setup
cat << EOF >$WD/portainer.service.setup.sh
cat << EOL >/lib/systemd/system/portainer.service
[Unit]
Description=portainer_Docker
Requires=docker.service network-online.target

[Service]

Restart=on-abnormal
ExecStart=/usr/bin/docker-compose --project-name portainer --project-directory $WD -f $WD/docker-compose.yaml up
ExecStop=/usr/bin/docker-compose --project-name portainer --project-directory $WD -f $WD/docker-compose.yaml stop

[Install]
WantedBy=multi-user.target
EOL
systemctl enable portainer
systemctl start portainer
EOF
chmod +x $WD/portainer.service.setup.sh
$WD/portainer.service.setup.sh


Add to XYMon:

nano /etc/xymon/analysis.cfg && systemctl restart xymon xymon-client
        PROC portainer
  • No labels