[SOLVED] Autoscale (docker+machine) throwing "bad certificate"

Currently, we’re using Gitlab CI with Gitlab Runner configured for autoscale on Digital Ocean.

This week we decided to migrate to AWS.
To do this, we followed this tutorial:

The runner seems to be picking the jobs accordingly and is even able to raise the instances and running ssh into them. But when it tries to talk to the remote docker, a tls error happens.

Here is what is happening:

Waiting for SSH to be available...    
Detecting the provisioner...
Provisioning with coreOS...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker... 

ERROR: Error creating machine: Error checking the host: Error checking and/or regenerating the certs: There was an error validating certificates for host "<remote-machine-ip>": remote error: tls: bad certificate#033

It’s worth noticing that I’m able to use docker-machine create to manually raise machines and run docker commands inside them without any trouble.

config.toml contents

concurrent = 5
check_interval = 0

  session_timeout = 1800

  name = "bastiao-aws"
  url = "https://gitlab.com"
  token = "<token>"
  executor = "docker+machine"
    tls_verify = false
    image = "alpine:latest"
    privileged = true
    disable_cache = false
    Type = "s3"
    Shared = true
      ServerAddress = "s3.amazonaws.com"
      AccessKey = "<access-key>"
      SecretKey = "<secret-key>"
      BucketName = "genebra-gitlab-ci"
      BucketLocation = "us-east-2"
      Insecure = true
    IdleCount = 0
    IdleTime = 180
    MachineDriver = "amazonec2"
    MachineName = "gitlab-docker-machine-%s"
    MachineOptions = [

It’s solved.
The problem was related to gitlab-runner being executed as root and the docker-machine certificates had previously been generated without root.

To solve it, I logged in a shell as root, removed the certs located in ~/.docker/machine/certs and ran a docker-machine create to manually create a machine (and recreate the removed certs as root). This regenerated the certificated with the correct user root. This solved the issue.

1 Like

Worked for me with a very similar issue. Thanks for posting.