Vagrant up failing: Could not get lock /var/lib/dpkg/lock

Rene Fragoso
Jul 11, 2016 · 1 min read

I ran into a problem recently where vagrant failed to bring up new vagrant boxes that were based on Ubuntu 16.04 (Xenial) boxes.

The problem was we were using NFS mounts and vagrant had to install nfs-common and portmap packages. Before it did so, it ran apt-get -yqq update, and this failed with error:

==> default: Could not get lock /var/lib/dpkg/lock — open (11: Resource temporarily unavailable)

While troubleshooting I found Ubuntu apt-daily service runs on boot and this runs apt-get update as part of its unattended installation system.

To work around this problem, I disabled the apt-daily systemd service from the Vagrantfile we use to build new vagrant boxes.

config.vm.provision "shell", inline: <<-SHELL
..
..
systemctl disable apt-daily.service
systemctl disable apt-daily.timer
SHELL

Rene Fragoso

Written by

Error 209 loading One Line Bio.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade