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: github.com/portainer/portainer/issues/12925

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