LoginSignup
4
2

More than 3 years have passed since last update.

「docker-machine env」実行時のエラー対処法

Last updated at Posted at 2019-06-01

はじめに

「docker-machine env」を実行した際、エラーが出たので対処法をまとめました

TL;DR

「docker-machine regenerate-certs」コマンドを実行して、TLS証明書を再作成することでエラーを解消できました

エラー解消前の流れ

現在の状況は以下の通り

$ docker-machine ls
NAME        ACTIVE   DRIVER       STATE     URL   SWARM   DOCKER    ERRORS
hoge   -        virtualbox   Stopped                 Unknown   

hogeを起動します


$ docker-machine start hoge
Starting "hoge"...
(hoge) Check network to re-create if needed...
(hoge) Waiting for an IP...
Machine "hoge" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.

「docker-machine env hoge」を行ったところ、エラーが発生しました

$ docker-machine env hoge
Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.100:2376": x509: certificate is valid for 192.168.99.101, not 192.168.99.100
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.

エラーにあるコマンドを実行します

$ docker-machine regenerate-certs hoge
Regenerate TLS machine certs?  Warning: this is irreversible. (y/n): y
Regenerating TLS certificates
Waiting for SSH to be available...
Detecting the provisioner...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...

もう一度、「docker-machine env hoge」を行います。今度はエラーがありませんでした

$ docker-machine env hoge
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/xxx/.docker/machine/machines/hoge"
export DOCKER_MACHINE_NAME="hoge"
# Run this command to configure your shell: 
# eval $(docker-machine env hoge)

hogeをactiveにします

$ eval $(docker-machine env hoge)

無事にhogeがActiveになりました

$ docker-machine ls
NAME        ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER     ERRORS
hoge   *        virtualbox   Running   tcp://192.168.99.100:2376           v18.09.6

まとめ

「docker-machine env」でエラーが出たときは、参考にしてみてください

参考

regenerate-certs

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2