docker / machine

Machine management for a container-centric world
https://docs.docker.com/machine/
Apache License 2.0
6.63k stars 1.96k forks source link

Docker-machine Ubuntu 16.04 creation error on Openstack #3522

Open allamand opened 8 years ago

allamand commented 8 years ago

From times to times I have this error while creating a machine with openstack driver :

Creating machine...
(master1) Creating machine...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with ubuntu(systemd)...
Error creating machine: Error running provisioning: Something went wrong running an SSH command!
command : sudo apt-get update
err     : exit status 100
output  : Hit:1 http://security.ubuntu.com/ubuntu xenial-security InRelease
Hit:2 http://nova.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Hit:3 http://nova.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:4 http://nova.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

and machine stop there.

Generally If I make a docker-machine regenerate-certs, the process continue good and it works. But because I was creating a swarm, the swarm part has not be treated.

Perhaps the best way would be that machine handle this error and retry later If the resource is temporarily unavailable

thanks

robvelor commented 7 years ago

This happens to me on amazonec2 too. Sometimes it happens sometimes it doesn't, which leads be to believe it is a race condition. I am using docker-machine 0.8.2.

robvelor commented 7 years ago

No word on this?

safizn commented 7 years ago

I can confirm, it happens to me too. On Windows host, using generic driver to create/add Google cloud compute instance. Cannot seem to fix it.

Command used: docker-machine create --driver generic --generic-ip-address <VM IP> --generic-ssh-user <SSH User> --generic-ssh-key ~/.ssh/google_compute_engine <VM Name>

After it fails I try to provision the added docker-machine using: docker-machine provision <VM Name>

Which results in the same error. Sometimes the status of VM shows timeout other times stopped when executing docker-machine ls.

Any provided solution ?

Docker version 1.13.1, build 092cba3

safizn commented 7 years ago

My error:

$ docker-machine provision vm
Waiting for SSH to be available...
Detecting the provisioner...
Error running apt-get update: ssh command error:
command : sudo apt-get update
err     : exit status 100
output  : Hit http://security.debian.org jessie/updates InRelease
Ign http://http.debian.net jessie InRelease
Hit http://security.debian.org jessie/updates/non-free amd64 Packages
Hit http://security.debian.org jessie/updates/non-free Translation-en
Hit http://security.debian.org jessie/updates/main amd64 Packages
Hit http://security.debian.org jessie/updates/contrib amd64 Packages
Ign http://gce_debian_mirror.storage.googleapis.com jessie InRelease
Hit http://security.debian.org jessie/updates/contrib Translation-en
Hit http://security.debian.org jessie/updates/main Translation-en
Hit http://http.debian.net jessie-backports InRelease
Hit http://gce_debian_mirror.storage.googleapis.com jessie-updates InRelease
Get:1 http://http.debian.net jessie-backports/main Sources/DiffIndex [27.8 kB]
Hit http://gce_debian_mirror.storage.googleapis.com jessie-backports InRelease
Hit http://http.debian.net jessie Release.gpg
Hit http://gce_debian_mirror.storage.googleapis.com jessie Release.gpg
Get:2 http://http.debian.net jessie-backports/main Translation-en/DiffIndex [27.8 kB]
...
Hit http://gce_debian_mirror.storage.googleapis.com jessie/main Translation-en
Hit http://gce_debian_mirror.storage.googleapis.com jessie/non-free Translation-en
Get:64 http://http.debian.net jessie-backports/main amd64 2017-02-08-0222.51.pdiff [906 B]
...
Get:69 http://http.debian.net jessie-backports/main amd64 2017-02-09-0222.49.pdiff [2,664 B]
Hit http://http.debian.net jessie/main Translation-en
Fetched 314 kB in 5s (57.2 kB/s)
W: Failed to fetch http://http.debian.net/debian/dists/jessie-backports/main/source/SourcesIndex  Hash Sum mismatch

W: Failed to fetch http://http.debian.net/debian/dists/jessie-backports/main/binary-amd64/PackagesIndex  Hash Sum mismatch

E: Some index files failed to download. They have been ignored, or old ones used instead.
robvelor commented 7 years ago
Running pre-create checks...
Creating machine...
(mymachine) Launching instance...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with ubuntu(systemd)...
Error creating machine: Error running provisioning: Something went wrong running an SSH command!
command : sudo apt-get update
err     : exit status 100
output  : Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:4 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:5 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main Sources [230 kB]
Get:6 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/restricted Sources [2,688 B]
Get:7 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/universe Sources [130 kB]
Get:8 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [474 kB]
Get:9 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [188 kB]
Get:10 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [7,176 B]
Get:11 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/restricted Translation-en [2,396 B]
Get:12 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [397 kB]
Get:13 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [149 kB]
Get:14 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [8,080 B]
Get:15 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-backports/main Sources [3,200 B]
Get:16 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [4,672 B]
Get:17 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-backports/main Translation-en [3,200 B]
Get:18 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [2,512 B]
Get:19 http://security.ubuntu.com/ubuntu xenial-security/main Sources [59.7 kB]
Get:20 http://security.ubuntu.com/ubuntu xenial-security/restricted Sources [2,288 B]
Get:21 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [19.7 kB]
Get:22 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [212 kB]
Get:23 http://security.ubuntu.com/ubuntu xenial-security/main Translation-en [88.8 kB]
Get:24 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [6,828 B]
Get:25 http://security.ubuntu.com/ubuntu xenial-security/restricted Translation-en [2,272 B]
Get:26 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [74.2 kB]
Get:27 http://security.ubuntu.com/ubuntu xenial-security/universe Translation-en [41.9 kB]
Fetched 2,415 kB in 3s (762 kB/s)
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it
safizn commented 7 years ago

@robvelor turns out for me the issue was concerning the user used in the SSH connection. I used a different user that than the one used to create the VM using docker-machine. The default user is docker-user. And so the same apparently should be used when adding a generic VM .

robvelor commented 7 years ago

@myuseringithub I updated to docker-machine 0.9.0 and spooled many machines since then, I have not been able to reproduce this issue since then.

polinchw commented 7 years ago

I'm getting this same error. The user I'm using is 'ubuntu' on the Docker Machine and the target EC2 instance.

CharmingSteve commented 7 years ago

I get this on EC2 every couple of weeks, then I make a new AMI. I pray for a superior solution

dtitov commented 6 years ago

Same for me. Any update?

robvelor commented 6 years ago

@dtitov FYI, I ended up using SvenDowideit solution here: https://github.com/docker/machine/issues/4091

We shouldn't be forced to install the latest docker.

ldealmei commented 5 years ago

I ran into that issue as well when using docker-machine to connect to an existing EC2 instance (instantiated just before and based on a custom AMI using boto3).

Everything worked fine at first, then the lock error popped up. In my case the issue was that the UnattendedUpgrades process would start running when the instance is launched, preventing docker-machine to access the dpkg resources

I solved the issue by modifying the conf file of UnattendedUpgrades and uncommented this line: Unattended-Upgrade::InstallOnShutdown "true";