Skip to main content

Portainer

DISCLAIMER: The information in this guide is provided "as is" without any guarantee of completeness, accuracy, timeliness, or of the results obtained from the use of this information. The author assumes no responsibility for any errors or omissions in the content. It is meant for general information purposes only and should not be used as a substitute for professional advice. The author is not responsible for any damages caused by the use of this information. By using this guide, you agree to hold the author harmless from any and all claims, damages, or expenses that may arise from your use of the information.


Introduction

Portainer's hybrid & multi-cloud container management platform supports Kubernetes, Docker, Swarm in any Data Center, Cloud, Network Edge or IIoT Device.


Requirements

The following requirement(s) assumes that the container/app will not be internet/public facing:


Deployment

Via CLI

Docker CLI

  1. Create the volume for the Portainer database:
    sudo docker volume create portainer_data
  2. Install Portainer:
    sudo docker run -e "America/Chicago" -d -p 8000:8000 -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

Via Docker Compose (Preferred)

---

services:
  portainer:
    image: portainer/portainer-ce:latest
    container_name: portainer
    restart: always
    ports:
      - 8000:8000
      - 9443:9443
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data

volumes:
  portainer_data:
    external: true

Post Deployment

Login

  1. Visit the Portainer URL to create the initial administrator user:
    URL https://<ip>:9443 or https://<hostname>:9443

  2. Change user information as needed, such as your User/Email and Password.

Update via CLI

  1. Stop the Portainer container.
    sudo docker stop portainer
  2. Remove the Portainer container.
    sudo docker rm portainer
  3. Get the Portainer image id:
    sudo docker image ls | grep portainer
  4. Remove the Portainer image using the image id from the previous step:
    sudo docker image rm xxxxxxxxxxxx

    OR

    sudo docker rmi -f $(sudo docker images --format '{{.Repository}}:{{.Tag}}' | grep 'portainer')
  5. Run the following command to create a new container from pulled image:
    sudo docker run -d -p 8000:8000 -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

Update via Docker Compose

  1. Stop the container:
    sudo docker compose stop
  2. Pull the new image:
    sudo docker compose pull
  3. Start the container:
    sudo docker compose up -d

     

  4. Prune unused images:
    sudo docker image prune -f

Royal TS Key Sequence Task (Upgrade)

This section and any subsections are unique to Marthur's home lab environment.

Royal TS provides easy and secure access to remote systems. It allows the use of "Key Sequence Tasks" to automate jobs. I've included the follow key sequence tasks to automate the upgrade process.

sudo docker stop portainer{ENTER}{WAIT:3000}
sudo docker rm portainer{ENTER}{WAIT:3000}
sudo docker rmi -f $(sudo docker images --format '{{.Repository}}:{{.Tag}}' | grep 'portainer')
sudo docker run -d -p 8000:8000 -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

Sources


KB Change/Issue Log

yyyy/mm/dd - Title

Issue

N/A

Solution

N/A


KB Meta

Page Includes @9#bkmrk-callout-danger-NoResponsibilityDisclaimer-5wod5ufe