Inconsistency in rootless mode configuration

I am reading the Docker documentation regarding the configuration of rootless mode. I don’t understand why at one point it says:

    [INFO] Make sure the following environment variables are set (or add them to ~/.bashrc):
    export PATH=/usr/bin:$PATH
    export DOCKER_HOST=unix:///run/user/1000/docker.sock

However, later on, we learn that we need to directly select a context by issuing the command:

docker context use rootless

But doing this results in a warning:

    docker context use rootless
    Current context is now "rootless"
    Warning: DOCKER_HOST environment variable overrides the active context. To use "rootless", either set the global --context flag, or unset DOCKER_HOST environment variable.

So, setting the DOCKER_HOST variable earlier now causes an error, and the recommended solution is to perform an “unset” on a variable that we were previously supposed to set.

Can someone explain this to me?

That is just the quoted output of the setuptool. It could have mentioned changing the context as well, but later the documentation does it and says you can either set the DOCKER_HOST variable or change the context. If you set the variable, all contexts will use the same docker host which is set in the variable.

1 Like