Portainer: Failed loading environment The environment named local is unreachable

This command does not work anymore, hence the image is never removed:

docker image ls -a | mawk '/portainer\/portainer(-ce)?( |$)/{print $3;exit}'

Looks like this commit which was meant as enhancement to support Portainer BE upgrades, turned now into a bug fix at the same time: dietpi-software: Portainer: handle BE correctly by MichaIng · Pull Request #7832 · MichaIng/DietPi · GitHub
When I implemented this, the previous command still worked. What changed it:

  • The image name is now suffixed with the version/tag.
  • The image ID is now 2nd field instead of 3rd

Funnily I implemented exactly what they suggest now, before this warning was even emitted: using the --format option, as well as the --filter/-f one, instead of using mawk :smile:.

@Pi-Rate try this, the code a reinstall will run next DietPi version:

# 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"
1 Like