GCPのインスタンスに作ったdocker-machineのIPが変わったとき

Table of Contents

docker-machine env をするとエラー

 eval "$(docker-machine env vm01)"

Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "111.222.333.444:2376": x509: certificate is valid for 111.222.333.444, not 555.666.777.888
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.
  • vm01はdocker-machineの名前
  • 111.222.333.444(仮)は最初にGCPのインスタンスに作ったdocker-machineのIP
  • 555.666.777.888(仮)はGCPのインスタンスのIP変更後のIP

docker-machine ls で確認

$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL   SWARM   DOCKER    ERRORS
vm01      -    google   Running   tcp://555.666.777.888:2376        Unknown   Unable to query docker version: Get https://555.666.777.888:2376/v1.15/version: x509: certificate is valid for 111.222.333.444, not 555.666.777.888

TLS 証明書を再生成

docker-machine regenerate-certs vm01

docker-machine ls で確認

NAME      ACTIVE   DRIVER       STATE     URL   SWARM   DOCKER    ERRORS
vm01      -    google   Running   tcp://555.666.777.888:2376        v18.05.0-ce

これで大丈夫そう。

タイトルとURLをコピーしました