Portainer Issues With Docker Update FYI

submitted by edited

If you just updated Docker and are having issues with Portainer not connecting to the environment, check this:

Issue: Failed loading environment The environment named <your specific environment> is unreachable

Fix (credit xman601):

Stop Docker

sudo systemctl stop docker

Make sure you have the Docker official repository added for your Ubuntu version. In my case Ubuntu Jammy

sudo apt update
sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg


echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  jammy stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt update

Install the specific Docker version

sudo apt install docker-ce=5:28.5.2-1~ubuntu.24.04~noble \
                 docker-ce-cli=5:28.5.2-1~ubuntu.24.04~noble \
                 containerd.io

or if you are on 22:

sudo apt install docker-ce=5:28.5.2-1~ubuntu.22.04~jammy \
                 docker-ce-cli=5:28.5.2-1~ubuntu.22.04~jammy \
                 containerd.io
sudo apt install docker-ce=5:28.5.2-1~ubuntu.22.04~jammy \
                 docker-ce-cli=5:28.5.2-1~ubuntu.22.04~jammy \
                 containerd.io

Prevent Ubuntu from automatically upgrading Docker:

sudo apt-mark hold docker-ce docker-ce-cli

Start Docker again

sudo systemctl start docker
sudo systemctl enable docker

Verify the version

docker --version

You should see:

Docker version 28.5.2, build …

Once this issue has been fixed you can run the following to update docker back

sudo apt-mark unhold docker-ce docker-ce-cli

Referance: https://github.com/portainer/portainer/issues/12925

It should go without saying, you should do your due diligence reviewing and confirming any code snippets found on the internet before you drop them in on a production environment.

8
17

Log in to comment

8 Comments

You can also add an override for the docker.service file to specify min api version 1.24. Had to do that last night

add an override for the docker.service file

Can you elaborate? I made the post hoping to save someone a couple hours banging their head on the keyboard like I did. LOL

So something like :

sudo nano /usr/lib/systemd/system/docker.service

What was the format of your entry to specify a minimum api version 1.24? I’m curious and always down to learn new tricks.

‘presh

You just need to do the following:

  1. systemctl edit docker.service

  2. Add this part above the line ### Lines below this comment will be discarded:

[Service] Environment=DOCKER_MIN_API_VERSION=1.24

  1. Save the file and exit

  2. systemctl restart docker

Credit to johannesMEGABAD
https://github.com/portainer/portainer/issues/12925#issuecomment-3516549977

Here’s the method I used from one of the issues on GitHub https://github.com/portainer/portainer/issues/12925#issuecomment-3516549977

Iirc my docker.socket wouldn’t let me just stop docker.service to edit it as described in the post, so I made /etc/systemd/system/docker.service.d/override.conf with the 2 required lines. After saving it and running daemon-reload I was able to access my containers in portainer again.

Alright! Alright! More ways to skin a cat. Thanks.

Thank you a thousand times, today it caught me.

No problem, glad I could help. Thank xman601. I posted it here hoping to save someone a couple hours banging their head on the keyboard like I did. I noticed Portainer released update 2.33.4 a couple days ago, but I haven’t had time to see if it covers the API issue.

Insert image