Update Docker app to latest version

After a while of getting acquainted with Docker, I have mastered the basic commands of Docker, so I rarely access Portainer to manage containers. Today, when I access it again, I see that Portainer has announced that there is a new version: A new version is available.

By the way, upgrading Portainer to the latest version, I always share the instructions on the blog. Probably will help many of you who are new to Docker.

Portaler announced that there is a new version, need to update

How to update your Docker application to the latest version will depend on how you initialize the application: via the command docker run or through Docker-Compose.

Update application initialized with Docker-Compose

With the current Portainer application, I initialize it using Docker-Compose

services:
  portainer:
    image: portainer/portainer-ce:alpine
    container_name: portainer
    command: -H unix:///var/run/docker.sock
    ports:
      - "9000:9000"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "portainer_data:/data"
    restart: always

volumes:
  portainer_data:

To update to the latest version, first need to pull the latest Docker image to your machine with the following command. Note: need to access the directory containing the file docker-compose.yml of the app before entering the command

docker-compose pull

Re-initialize the new container based on the downloaded image. I added the suffix --remove-orphans to remove containers that are no longer in use.

docker-compose up -d --remove-orphans

Enter the following command to delete the old image that is no longer in use.

docker image prune

Visit Portainer again, the app has been updated to the latest version 2.14.2.

Update Application initialized with docker run

If you run the application directly through the command docker run, the method will be slightly different. First, you need to pull the new image with the following command

docker pull portainer/portainer-ce:alpine

Replace portainer/portainer-ce:alpine with the corresponding Docker image name of the application you need to update.

Check the ID of the active application with the command

docker ps

According to the returned results, Portainer’s Container ID is a3ca0e0f360b

CONTAINER ID   IMAGE                             COMMAND                  CREATED        STATUS                  PORTS                                                                                                                                                                                                                                                                                                 NAMES
a3ca0e0f360b   portainer/portainer-ce:alpine     "/portainer -H unix:…"   2 days ago     Up 30 hours             8000/tcp, 9443/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp                                                                                                                                                                                                                                         portainer
5e963e0c4588   jc21/nginx-proxy-manager:latest   "/init"                  5 weeks ago    Up 30 hours             0.0.0.0:80-81->80-81/tcp, :::80-81->80-81/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp                                                                                                                                                                                                                  nginxproxymanager_app_1
641c6af1efd7   guacamole/guacamole               "/opt/guacamole/bin/…"   2 months ago   Up 30 hours             0.0.0.0:8080->8080/tcp, :::8080->8080/tcp                                                                                                                                                                                                                                                             guacamole_compose
9869abf6ba12   guacamole/guacd                   "/bin/sh -c '/usr/lo…"   2 months ago   Up 30 hours (healthy)   4822/tcp                                                                                                                                                                                                                                                                                              guacd_compose
5a0ceb014be9   postgres:13.4                     "docker-entrypoint.s…"   2 months ago   Up 30 hours             5432/tcp                                                                                                                                                                                                                                                                                              postgres_guacamole_compose

Suspend and delete running containers

sudo docker stop a3ca0e0f360b
sudo docker rm a3ca0e0f360b

Re-initialize the new container for the application

sudo docker run --name=[container_name] [options] [docker_image]

With Portainer, the initialization command will be as follows

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:alpine

It is done!

If my article has been beneficial in providing valuable information and knowledge, don’t hesitate to express your gratitude through a kind message or a virtual shout-out. Your encouragement will drive me to continue sharing informative content. And, if you’re feeling generous, a donation would be greatly appreciated as it would further motivate me to keep writing. Thank you for taking the time to read!

Leave a Reply

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