x509: certificate is valid for 192.168.99.103, not 192.168.99.100
After having my machine running on the .103 IP I rebooted my Mac. Upon reboot my docker-machine switched to the .100 address. When I tried to perform any docker commands on my machine I get things like this:
docker exec -it mycontainer bash:
FATA[0000] An error occurred trying to connect: Post https://192.168.99.100:2376/v1.16/containers/mycontainer/exec: x509: certificate is valid for 192.168.99.103, not 192.168.99.100
Can you give some more detail on the issue?
- What version of Machine?
- What driver (I'm assuming vbox based upon the IP)?
- Command line used to create machine
Thanks
docker-machine version 0.1.0 virtualbox docker-machine create -d virtualbox --virtualbox-disk-size '40000' --virtualbox-memory '4096' devbox
I also added an --insecure-registry to the daemon so I could talk to our private registry (if that matters).
Would you mind testing from master (you can use https://docker-machine-builds.evanhazlett.com/latest/ if you don't want to build locally). I have tested this with VMs changing IPs and everything works as expected:
ehazlett machine> docker-machine ls
NAME ACTIVE DRIVER STATE URL
test-vbox * virtualbox Running tcp://192.168.99.100:2376
ehazlett machine> docker-machine stop test-vbox
ehazlett machine> docker-machine create -d virtualbox test-vbox-2
...
ehazlett machine> docker-machine ls
NAME ACTIVE DRIVER STATE URL
test-vbox virtualbox Stopped
test-vbox-2 * virtualbox Running tcp://192.168.99.100:2376
ehazlett machine> docker-machine start test-vbox
...
ehazlett machine> docker-machine ls
NAME ACTIVE DRIVER STATE URL
test-vbox virtualbox Running tcp://192.168.99.101:2376
test-vbox-2 * virtualbox Running tcp://192.168.99.100:2376
ehazlett machine> docker $(docker-machine config test-vbox) ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
You can see that test-vbox switched IPs.
Ok, here is what I did:
Stop the current machine Start using the new machine bin "machine ls" with new machine was ok and shows: "devbox * virtualbox Running tcp://192.168.99.100:2376 devbox2 virtualbox Stopped"
"docker info" produces: FATA[0000] An error occurred trying to connect: Get https://192.168.99.100:2376/v1.16/info: x509: certificate is valid for 192.168.99.103, not 192.168.99.100
thanks. did you try with the master build above? I ran the same procedure you did and I didn't have any cert issues.
I downloaded that "latest" binary.
Hmm ok. @sthulb can you try to see if you can reproduce this?
- Create a virtualbox machine
- Stop first machine
- Create second virtualbox machine
- Start first machine
- Check that the first machine IP changed
- Check if you can access the docker daemon on both
@stephenlawrence is that process correct?
Thanks
@ehazlett Technically this is not how it started. It started when I rebooted my Mac and the DM came up with a different IP on the reboot. I don't know if that is different than just doing what you describe. But now, any attempts at accessing that previously-working machine result in the x509 message.
@stephenlawrence i cannot re-create that as my IP always changes and the VM stays. I simply emulated the VM getting a different IP which should create the same thing I believe. Would you mind trying the above with the new binary and a fresh set of VMs? I'm wondering if the certs were created using an old build not using the correct process or something.
@stephenlawrence Are you sure you don't have something in your bashrc that is messing with your settings, like DOCKER_CERT_PATH?
Since I didn't see anyone else reference the relevant code, I'll just point out that machine is creating a certificate with the IP address in it here: https://github.com/docker/machine/blob/973b267fec3ec0a900e26557475b387891c0138a/host.go#L123
If the IP address changes, that cert will no longer work.
In the b2d init scripts, there is code that regenerates the server certificates if the relevant IP addresses change: https://github.com/boot2docker/boot2docker/blob/5db7efbb4e0557f6efefdb56cb0263f80ed55834/rootfs/rootfs/usr/local/etc/init.d/docker#L46
I'm not entirely sure why that bit of b2d code isn't triggered in the machine case since I thought you guys were using the b2d ISO.
Yeah thanks, I know this code is there however, when the IP changed (as shown above) there were no issues when testing so I'm trying to at least get this re-producable to test.
On Sat, Feb 14, 2015 at 12:58 AM, Mike Dillon [email protected] wrote:
Since I didn't see anyone else reference the relevant code, I'll just point out that machine is creating a certificate with the IP address in it here: https://github.com/docker/machine/blob/973b267fec3ec0a900e26557475b387891c0138a/host.go#L123
If the IP address changes, that cert will no longer work.
In the b2d init scripts, there is code that regenerates the server certificates if the relevant IP addresses change: https://github.com/boot2docker/boot2docker/blob/5db7efbb4e0557f6efefdb56cb0263f80ed55834/rootfs/rootfs/usr/local/etc/init.d/docker#L46
I'm not entirely sure why that bit of b2d code isn't triggered in the machine case since I thought you guys were using the b2d ISO.
— Reply to this email directly or view it on GitHub https://github.com/docker/machine/issues/531#issuecomment-74363452.
@md5 @stephenlawrence would you mind checking to see if you have anything that would be using the b2d certs by chance? after debugging, it looks like the b2d certs are being used with machine.
@ehazlett I'm not sure what you're asking me to check.
@md5 sorry i should have been more clear. check the environment variables DOCKER_CERT_PATH and DOCKER_HOST to see if they are pointed at the correct machine. It sounds like the the DOCKER_CERT_PATH may be configured to the b2d certs when accessing a machine or vice versa.
@ehazlett if this were a case of an incorrect DOCKER_CERT_PATH, it would be a different error. The problem in that situation would either be that ca.pem is not a trust root for the cert presented by the Docker server on the machine-controlled instance or that the cert.pem client certificate is not accepted by the server.
The error that we're seeing here is clearly that the client (i.e. docker exec) is not accepting the server's certificate. It's attempting to hit the server at 192.168.99.100, but the server is presenting a certificate that is only valid for 192.168.99.103. This can only mean that a server that is responding at 192.168.99.100 on port 2376 is configured to use a certificate that was created for 192.168.99.103.
@md5 that makes sense. how do i re-create? as you can see above i've changed the IP of my virtualbox instances and don't see this issue.
That's a good question. I haven't been able to reproduce it myself either.
Closing as we cannot seem to reproduce. My suspicion is that the environment variables are getting mixed for the boot2docker VM and the machine instance. I would recommend to check your .bashrc etc for anything that may be setting them.
I have this issue happening again. I had a docker-machine running on 192.168.99.101, and after a re-boot of my Mac, that machine is now running on 192.168.99.100.
This seems as if its a docker issue since I can do "docker-compose run" into a container OK, but trying any docker commands throws this error:
$docker ps FATA[0000] An error occurred trying to connect: Get https://192.168.99.100:2376/v1.17/containers/json: x509: certificate is valid for 192.168.99.101, not 192.168.99.100