Docker & Portainer Update

Overview

For any new Helmut4 installation, the latest versions of Docker and Portainer CE (community version) will always be downloaded and installed.

For more information, please refer to the Helmut4 Server documentation.

Updates

Subsequent updates or upgrades of Docker and Portainer are the responsibility of the customer or hosting support. Helmut4 updates do not manage the current versions of Docker and Portainer.

When performing updates, please review the specific release notes for Docker and Portainer to ensure compatibility. It's important to test updates first in a staging environment before applying them to the production environment.

For more information, refer to:

Portainer Update

With the release of Docker v26, Portainer has introduced a new release principle for its product: https://www.portainer.io/blog/2024-release-principle

  • LTS (Long-Term Support) versions can be identified by the tag :lts

  • STS (Short-Term Support) versions can be identified by the tag :sts

Remove and re-deploy latest Portainer CE

Please use the provided script with caution, as Portainer is not within Helmut4's scope / support.

#!/bin/bash

# Update Portainer to the latest community edition

# moovIT GmbH - B. Dimmel

# Version 2.2
# Changelog: Apr 8th 2024
# Update Portainer from v1.x to 2.x
# Can also be used to update 2.x to a newer version
# Get container ID by 'names', making it more dynamically
# Add option to pick LTS or new STS Short-Term version
# changed tag latest to lts

# Prompt user for LTS, STS, or quit option
while true; do
    echo -e "\nDo you want to update to the latest LTS (Long-Term) or STS (Short-Term Support) version?\n"
    read -p "Enter 'lts', 'sts', or 'quit': " version_choice

    # Determine the Docker tag or abort based on user input
    case "$version_choice" in
        lts)
            docker_tag="portainer/portainer-ce:lts"
            break
            ;;
        sts)
            docker_tag="portainer/portainer-ce:sts"
            break
            ;;
        quit)  # Use 'quit' instead of 'q' for clarity
            echo -e "Portainer update aborted!\n"
            exit 0
            ;;
        *)
            echo -e "Invalid choice!\nPlease enter 'lts', 'sts', or 'quit'.\n"
            ;;
    esac
done

# Ask for confirmation before proceeding
while true; do
    echo -e "\n==> You have chosen: $version_choice <==\n"
    read -p "Proceed with this version? (y/n): " confirm_choice

    # Validate user confirmation
    case "$confirm_choice" in
        [yY])
            break
            ;;
        [nN])
            echo -e "Please choose again.\n"
            while true; do
                echo -e "Do you want to update to the latest LTS (Long-Term) or STS (Short-Term Support) version?\n"
                read -p "Enter 'lts', 'sts', or 'quit': " version_choice

                # Determine the Docker tag or abort based on user input
                case "$version_choice" in
                    lts)
                        docker_tag="portainer/portainer-ce:lts"
                        break
                        ;;
                    sts)
                        docker_tag="portainer/portainer-ce:sts"
                        break
                        ;;
                    quit)  # Use 'quit' instead of 'q' for consistency
                        echo -e "Portainer update aborted!\n"
                        exit 0
                        ;;
                    *)
                        echo -e "\n==> Invalid choice!\nPlease enter 'lts', 'sts', or 'quit' <==\n"
                        ;;
                esac
            done
            ;;
        *)
            echo "Invalid input. Please enter 'y' or 'n'."
            ;;
    esac
done

# Get the container ID of the container with the name "portainer"
container_id=$(docker ps -q --filter "name=portainer")

# Check if container_id is not empty
if [ -n "$container_id" ]; then
    echo "Container ID of the container 'portainer': $container_id"
else
    echo "No container with the name 'portainer' found."
    exit 1
fi

# Stop and remove the existing Portainer container
echo -e "\nStopping Portainer and deleting it's container ...\n"
if sudo docker stop "$container_id" && sudo docker rm "$container_id"; then
    echo "Portainer container stopped and removed successfully."
else
    echo "Failed to stop or remove Portainer container. Exiting."
    exit 1
fi

# Pull the latest Portainer Community Edition image
echo -e "\nPulling the latest Portainer-CE image ...\n"
if docker pull portainer/portainer-ce:latest; then
    echo "Latest Portainer-CE image pulled successfully."
else
    echo "Failed to pull the latest Portainer-CE image. Exiting."
    exit 1
fi

# Deploy the new Portainer container
echo -e "\nDeploying the new Portainer-CE container ...\n"
if docker run -it -d --restart=always -p 9000:9000 --name=portainer -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data "$docker_tag" -H unix:///var/run/docker.sock; then
    echo "Portainer Community Edition has been successfully deployed."
else
    echo "Failed to deploy Portainer Community Edition. Exiting."
    exit 1
fi

Docker Update

To update the Docker environment or engine, please refer to the documentation provided by your host operating system manufacturer, such as Ubuntu.

The update commands can vary depending on the distribution running on your server.

For guidance, you can consult the official Docker installation guide specific to Ubuntu: https://docs.docker.com/engine/install/ubuntu

Update Docker on Ubuntu / Debian
sudo apt update
sudo apt upgrade docker-ce
Update Docker on RHEL
sudo yum check-update
sudo yum update docker-ce