Docker Community Forums

Share and learn in the Docker community.

Docker-machine restart error ssh. Error getting machine state: google: could not find default credentials


(Pmrleite) #1

Issue type
docker-machine SSH error
OS Version/build
Debian 19
App version
docker-machine version 0.14.0, build 89b8332
docker version: 18.03.1-ce
gcloud version: Google Cloud SDK 204.0.0
Steps to reproduce
I had to install a new HDD into my machine, this is the same to say that I had to reinstall all my OS (Debian 19) and build all my docker, docker-machine structure.

I got docker running ok (localy)
$docker ps
list my machines and I can work fine with them locally…
This machine already was in production (and is) on google cloud platform…
I made an import of my machine but when I try to use docker-machine I got this error:

ERROR THAT I GET

if I run:

  • $gcloud compute config-ssh
    

I got the answer that is everything ok

  • You should now be able to use ssh/scp with your instances.
    For example, try running:
    $ ssh amraa-prod.europe-west1-b.gbli-2017-166-amraa-portal

My auth is ok to…

  • $gcloud auth list
    

    Credentialed Accounts
    ACTIVE ACCOUNT
    *my_email@gmail.com

  • To set the active account, run:
    $ gcloud config set account ACCOUNT

Wy I can’t put my machine active on docker-machine?.. I am stuck…

More info
Runnig:

  • $docker-machine restart amraa-prod
    

got

  • Restarting “amraa-prod”…
    Waiting for SSH to be available…

Runnig:

  • docker-machine --debug restart amraa-prod
    

got

  • Docker Machine Version: 0.14.0, build 89b8332
    Found binary path at /usr/local/bin/docker-machine
    Launching plugin server for driver google
    Plugin server listening at address 127.0.0.1:40509
    () Calling .GetVersion
    Using API Version 1
    () Calling .SetConfigRaw
    () Calling .GetMachineName
    command=restart machine=amraa-prod
    Restarting “amraa-prod”…
    (amraa-prod) Calling .GetState
    Error getting machine state: google: could not find default credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

more info

  • $docker-machine inspect amraa-prod
    

result into:

  • {
    “ConfigVersion”: 3,
    “Driver”: {
    “IPAddress”: “”,
    “MachineName”: “amraa-prod”,
    “SSHUser”: “docker-user”,
    “SSHPort”: 22,
    “SSHKeyPath”: “/home/pmleite/.docker/machine/machines/amraa-prod/id_rsa”,
    “StorePath”: “/home/pmleite/.docker/machine”,
    “SwarmMaster”: false,
    “SwarmHost”: “tcp://0.0.0.0:3376”,
    “SwarmDiscovery”: “”,
    “Zone”: “europe-west1-b”,
    “MachineType”: “n1-standard-1”,
    “MachineImage”: “ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20170721”,
    “DiskType”: “pd-ssd”,
    “Address”: “prod”,
    “Network”: “default”,
    “Subnetwork”: “”,
    “Preemptible”: false,
    “UseInternalIP”: false,
    “UseInternalIPOnly”: false,
    “Scopes”: “https…://www…nitoring.write”,
    “DiskSize”: 100,
    “Project”: “gbli-2017-166-amraa-portal”,
    “Tags”: “http-server,https-server”,
    “UseExisting”: false,
    “OpenPorts”: null
    },
    “DriverName”: “google”,
    “HostOptions”: {
    “Driver”: “”,
    “Memory”: 0,
    “Disk”: 0,
    “EngineOptions”: {
    “ArbitraryFlags”: [],
    “Dns”: null,
    “GraphDir”: “”,
    “Env”: [],
    “Ipv6”: false,
    “Insecurem/auth/devstorage.read_only,https…//www…googleapis.com/auth/logging.write,httRegistry”: [],
    “Labels”: [],
    “LogLevel”: “”,
    “StorageDriver”: “”,
    “SelinuxEnabled”: false,
    “TlsVerify”: true,
    “RegistryMirror”: [],
    "InstallURL": "link to get…docker…com"
    },
    “SwarmOptions”: {
    “IsSwarm”: false,
    “Address”: “”,
    “Discovery”: “”,
    “Agent”: false,
    “Master”: false,
    “Host”: “tcp://0.0.0.0:3376”,
    “Image”: “swarm:latest”,
    “Strategy”: “spread”,
    “Heartbeat”: 0,
    “Overcommit”: 0,
    “ArbitraryFlags”: [],
    “ArbitraryJoinFlags”: [],
    “Env”: null,
    “IsExperimental”: false
    },
    “AuthOptions”: {
    “CertDir”: “/home/pmleite/.docker/machine/certs”,
    “CaCertPath”: “/home/pmleite/.docker/machine/certs/amraa-prod/ca.pem”,
    “CaPrivateKeyPath”: “/home/pmleite/.docker/machine/certs/amraa-prod/ca-key.pem”,
    “CaCertRemotePath”: “”,
    “ServerCertPath”: “/home/pmleite/.docker/machine/machines/amraa-prod/server.pem”,
    “ServerKeyPath”: “/home/pmleite/.docker/machine/machines/amraa-prod/server-key.pem”,
    “ClientKeyPath”: “/home/pmleite/.docker/machine/certs/amraa-prod/key.pem”,
    “ServerCertRemotePath”: “”,
    “ServerKeyRemotePath”: “”,
    “ClientCertPath”: “/home/pmleite/.docker/machine/certs/amraa-prod/cert.pem”,
    “ServerCertSANs”: [],
    “StorePath”: “/home/pmleite/.docker/machine/machines/amraa-prod”
    }
    },
    “Name”: “amraa-prod”
    }

ATENTION
Some links I had to change because the restriction of 2 links on this posts…

.
.
.
.
.


(Pmrleite) #2

Solved…

execute:

  • $gcloud auth application-default login
    

then

  •   gcloud auth application-default print-access-token 
    

docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
amraa-prod - google Running tcp://35.195.8.141:2376 v18.04.0-ce

like a charm…