raketenbasis / docker-machine

0 stars 4 forks source link

How to create certificates? #1

Open iBobik opened 7 years ago

iBobik commented 7 years ago

Hi, I just copied certificates and keys created by my local docker-machine create, but it seems it can not be created this way.

When I tried to use it in GitLab CI like this:

review:
  image: raketenbasis/docker-machine
  stage: review
  script:
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
…

It just printed this errors:

To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env default
Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "example.com:2376": x509: certificate is valid for localhost, not example.com
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.

$ docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
section_end:1509531912:build_script
section_start:1509531912:after_script
Host already exists: "default"
section_end:1509531915:after_script
ERROR: Job failed: exit code 1
iBobik commented 7 years ago

Ok, so we need to use docker-machine create with exactly the same hostname and then copy certificates.