DietPi icon indicating copy to clipboard operation
DietPi copied to clipboard

DietPi-Software | Portainer: Failed loading environment

Open MichaIng opened this issue 1 month ago • 3 comments

The latest Docker version raised the default minimum API version to 1.44, while Portainer still uses the API version 1.41, hence fails to function properly, showing an error "Failed loading environment" in the UI.

Docker explains the background and 2 possible workarounds in their blog: https://www.docker.com/blog/docker-engine-version-29/#minimum-api-version-update

We recommend the option with the config file, and allowing no lower API version than the one Portainer uses. This command will do:

G_SUDO G_CONFIG_INJECT '"min-api-version":' '    "min-api-version": "1.41",' /etc/docker/daemon.json '^\{([[:space:]]|$)'
sudo systemctl restart docker

MichaIng avatar Nov 19 '25 15:11 MichaIng

hell yeah, glad i found this fix. thx

angryturtle-network avatar Nov 22 '25 01:11 angryturtle-network

Portainer 2.33.5 was just released, which fixes the issue: https://github.com/portainer/portainer/releases/tag/2.33.5

They did not fix it as elegantly as Traefik, which did it with automatic client-server API version negotiation. Portainer just raised the static API version, which means the issue can re-appear once Docker deprecates further old API versions: https://github.com/portainer/portainer/commit/e831971

Hence everyone can now update their Portainer image and remove the workaround:

sudo sed --follow-symlinks -i '/"min-api-version":/d' /etc/docker/daemon.json
## edit, see below! dietpi-software reinstall 185

MichaIng avatar Nov 27 '25 14:11 MichaIng

Coincidentally a recent Docker update from 2 hours ago changed/reordered the docker image ls -a output, which breaks our image detection and update on a reinstall. Double-coincidentally I implemented Portainer BE support last week, and changed the detection commands in the same turn, which now fixes this new issue, which appeared afterwards 😄: https://github.com/MichaIng/DietPi/pull/7832/files

Not too much magic, luckily, so instead of dietpi-software reinstall 185, run below commands to update Portainer to latest version, which is what dietpi-software will do from next release on:

# Remove existing container and image, including CE, BE, and old v1, and store image repo in variable to preserve BE instances
container=$(docker container ls -aqf 'ancestor=portainer/portainer' -f 'ancestor=portainer/portainer-ce' -f 'ancestor=portainer/portainer-ee')
[[ $container ]] && G_EXEC docker container rm -f "$container"
read -r image repo < <(docker image ls -af 'reference=portainer/portainer' -f 'reference=portainer/portainer-ce' -f 'reference=portainer/portainer-ee' --format '{{.ID}} {{.Repository}}')
[[ $image ]] && G_EXEC docker image rm "$image"

# Create volume if it does not exist yet
[[ $(docker volume ls -qf 'name=^portainer_data$') ]] || G_EXEC docker volume create portainer_data

# Deploy new Portainer container, migrate v1 to CE and preserve BE
[[ $repo == 'portainer/portainer-ee' ]] || repo='portainer/portainer-ce'
G_EXEC_OUTPUT=1 G_EXEC docker run -d -p '9002:9000' -p '9442:9443' --name=portainer --restart=always -v '/run/docker.sock:/var/run/docker.sock' -v '/etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt:ro' -v 'portainer_data:/data' "$repo"

MichaIng avatar Nov 27 '25 19:11 MichaIng