Dean Christian Armada
Dean Christian Armada

Reputation: 7364

Change the URL of a docker-machine

I created a machine via docker-machine create -d azure --azure-static-public-IP. But what I did is I intentionally changed the public IP address of that VM. With this move, I can not docker-machine ssh or any docker-machine related command. Seems like it’s still sending request to the previous public-IP. How can I change that IP and convert it to the new one? I tried docker-machine regenerate-certs and even changing the config.json but nothing going to be happened…

The only way I saw fixing this is to reverting back the previous public IP of that VM

Upvotes: 0

Views: 3584

Answers (2)

opHASnoNAME
opHASnoNAME

Reputation: 20726

You should be fine with a change of the IP in "config.json". For Example, if i have to change my IP on my default docker-machine, i would go here:

/Users/arne/.docker/machine/machines/default/config.json

Adjust the IP and run

docker-machine regenerate-certs myVM

This should work.

Upvotes: 2

Jason Ye
Jason Ye

Reputation: 13954

Do you mean when you run Docker-machine ssh got this error:

Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "13.91.60.237:2376": x509: certificate is valid for 40.112.218.127, not 13.91.60.237 You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'. Be advised that this will trigger a Docker daemon restart which might stop running containers.

In my test lab, my first IP address is 40.112.218.127, then I change it to 13.91.60.237, get this error.

Then I use this command to regenerate it:docker-machine regenerate-certs jasonvmm, like this:

[root@jasoncli@jasonye jasonvmm]# docker-machine regenerate-certs jasonvmm
Regenerate TLS machine certs?  Warning: this is irreversible. (y/n): y
Regenerating TLS certificates
Waiting for SSH to be available...
Detecting the provisioner...
Installing Docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
[root@jasoncli@jasonye jasonvmm]# docker-machine ssh jasonvmm
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-47-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

208 packages can be updated.
109 updates are security updates.


Last login: Fri Dec  8 06:22:09 2017 from 167.220.255.48

Also, we can use this command to check the new settings:docker-machine env jasonvmm

[root@jasoncli@jasonye jasonvmm]# docker-machine env jasonvmm
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://13.91.60.237:2376"
export DOCKER_CERT_PATH="/root/.docker/machine/machines/jasonvmm"
export DOCKER_MACHINE_NAME="jasonvmm"
# Run this command to configure your shell: 
# eval $(docker-machine env jasonvmm)

Please use this script to regenerate them docker-machine regenerate-certs VMname.

Hope this helps.

Upvotes: 0

Related Questions