I develop on a windows VDI that uses the WSL to run docker, and I'm actually using a remote docker daemon running on a Red Hat server. Locally, I have the
DOCKER_HOST variable set to the correct path to my docker daemon (
tcp://<userid>@<my server running the remote docker daemon>), but this environment variable is only recognized immediately after being set.
What I mean by this is, right now, if I run a docker command, I get the
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? error, but if I assign
DOCKER_HOST to itself with
$ export DOCKER_HOST=$DOCKER_HOST, future docker commands will now recognize the remote daemon I'm directing it to with that variable.
I've added this assignment to
DOCKER_HOST in my
~/.bashrc, and I can see that it's properly set when I reboot the shell and run
$ echo $DOCKER_HOST.
I expect docker commands to refer to the
DOCKER_HOST variable that is set within
~/.bashrc, who's presence is confirmed with
$ echo $DOCKER_HOST
Docker doesn't recognize this variable/this variable's value unless it is set in the active shell's session. I literally have to assign the variable to itself for docker to recognize it (e.g.
export DOCKER_HOST=$DOCKER_HOST) and only then will docker commands run against the remote daemon.
Why do I have to reset the
DOCKER_HOST variable for docker to be able to recognize it?
If I'm doing this incorrectly, what is the proper way?
I'm open to hearing that I'm in the wrong place with my question. I could see this being a Linux/WSL issue, or an issue with docker itself.