28
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

"docker-machine env"実行エラー - Error running connection boilerplate: Error checking and/or regenerating the certs:

Last updated at Posted at 2015-11-25

#| エラー内容

エラー内容
Error running connection boilerplate: 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.121, not 192.168.99.100

背景

Docker Machineを起動させ、docker-machine envコマンドを実行して環境変数の設定方法を確認しようとしたところ、このようなエラーが発生しました。

エラー発生時
$ docker-machine start kooohei-test
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.

$ docker-machine env kooohei-test
Error running connection boilerplate: 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.121, 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 will stop running containers.

原因

内容を見てみると、なにやらエラー文の末尾に記載されている「certificate is valid for 192.168.99.121, not 192.168.99.100」がポイントそうです。
「このDocker Machineのcertificate(認証書)は”192.168.99.100”ではなく"192.168.99.121"です」という内容が記載されています。

ということで現在のIPを確認してみます。

DockerMachine一覧
$ docker-machine ls
NAME           ACTIVE   DRIVER       STATE     URL                         SWARM
default        -        virtualbox   Stopped                               
kooohei-test   -        virtualbox   Running   tcp://192.168.99.100:2376 

確かに今回の"kooohei-test"は"192.168.99.100"で起動しています。ですが、前回起動していた時のIPを思い出すと"192.168.99.121"でした。

#| 解決方法

TLS証明書を再度作成し直してあげればOKです。

文法
文法: docker-machine regenerate-certs NAME

それでは作成してみます。

TLS証明書の再作成
$ docker-machine regenerate-certs kooohei-test
Regenerate TLS machine certs?  Warning: this is irreversible. (y/n): y
Regenerating TLS certificates
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...

作成が完了したら再度、Docker Machineを確認してみます。

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

これで無事エラーが解消され環境変数の設定方法が表示されました。

28
26
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
28
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?