Search code examples
linuxdockernetwork-programmingraspbian

Docker host config has wrong IP address


I'm trying to install Docker on Raspbian but it seems to have picked up an old config from somewhere. No idea where from, as I can't find any references anywhere.

I have installed Docker on Raspbian using sudo apt-get install docker-ce.

When I try to connect to Docker, it tries to connect to the wrong IP address (192.168.1.75 when it should be 192.168.1.227).

$ docker ps
error during connect: Get http://192.168.1.75:2376/v1.38/containers/json: dial tcp 192.168.1.75:2376: connect: no route to host

The server used to be on 192.168.1.75 but is now on 192.168.1.227.

$ ifconfig eth0
eth0      Link encap:Ethernet  HWaddr b8:27:eb:50:b4:16  
          inet addr:192.168.1.227  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:42704 errors:0 dropped:0 overruns:0 frame:0
          TX packets:61093 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:6278037 (5.9 MiB)  TX bytes:80578119 (76.8 MiB)

I've tried rebooting the server, deleting the contents of the /var/run/docker folder, and even reinstalling Docker. It's still determined that the IP address is 192.168.1.75.


Solution

  • You can set the machine where the docker command tries to connect with the DOCKER_HOST environment variable:

    export DOCKER_HOST="tcp://192.168.1.227:2376"

    But it's strange that you have to do this on a default installation, perhaps they is a DOCKER_HOST variable in you bash/zsh profile that cause this problem ?