Docker Community Forums

Share and learn in the Docker community.

Change docker engine default port from machine

(Salvettimarc) #1


I have a docker host imported using the generic driver that was present in my docker machine, but on a local network IP using the default 2376 port. I have now moved that machine in another network which unfortunately has the port 2376 closed by the provider.
Using nmap, I have checked for other opened ports and found amongst others the port 554 that was opened and didn’t seem to be in use so I mapped it to 2376 for the local ip of my host.

Now I am trying to re-import the host on the port 554 using docker-machine create with the --generic-engine-port flag but the import fails with the following message
Error creating machine: Error checking the host: Error checking and/or regenerating the certs: There was an error validating certificates for host “x.x.x.x:554”: dial tcp x.x.x.x:554: getsockopt: connection refused

I think I understand that this is because the host is already existing and running on the host 2376 so machine cannot connect to it on port 554, or maybe is it that machine needs the internal engine port to be set the same as the external port ?

Either way, what can I do to get the host back into machine ?

at the moment the engine is running but I’m locked outside. I cannot even run docker commands using ssh, which seems normal as the host expect to be controlled by machine, at least I suppose.

machine version 0.7.0
engine 1.11.2

Thanks for any help

(Salvettimarc) #2

just answering to my own message hoping it will be helpful to someone as I found how to do it :slight_smile:

the host is running ubuntu 16.04 so have to edit systemd config using ssh directly on the host :

sudo nano /etc/systemd/system/docker.service

then change the port number and restart docker

sudo systemctl restart docker

then go back to docker-machine and re-import the host

docker-machine rm hostname

docker machine create [options] hostname