Shell Provisioner - Could not get lock /var/lib/dpkg/lock

1,617 views
Skip to first unread message

Joanna .Leong

unread,
Jul 7, 2017, 6:08:17 PM7/7/17
to Packer
Hi,

I'm running packer and have a shell provisioner executing command "apt-get update" and also tried "sudo apt-get update" and also tried sleeping before executing these commands. Regardless I keep getting the error:

Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
Unable to lock the administration directory (/var/lib/dpkg/)%!(PACKER_COMMA) is another process using it?

No matter how long I sleep I keep seeing this error.

Joanna .Leong

unread,
Jul 7, 2017, 6:21:14 PM7/7/17
to Packer
correction i mean when executing any package installation like:
                "sudo apt-get install -y swig",

Rickard von Essen

unread,
Jul 8, 2017, 5:09:16 AM7/8/17
to packe...@googlegroups.com
Guessing you are running Ubuntu and you have automatic updates on. 

See this thread for different solutions https://github.com/boxcutter/ubuntu/issues/86

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/9c599b9a-0fef-4042-8d31-3ec99934aa75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joanna .Leong

unread,
Jul 13, 2017, 7:59:10 PM7/13/17
to Packer
I've added the following to the beginning of my shell provisioning script:
sudo systemctl disable apt-daily.service # disable run when system boot
sudo systemctl disable apt-daily.timer   # disable timer run

# Disable daily apt unattended updates.
sudo echo 'APT::Periodic::Enable "0";' >> /etc/apt/apt.conf.d/10periodic

but doesn't seem to help. am i understanding this incorrectly?

On Saturday, July 8, 2017 at 2:09:16 AM UTC-7, Rickard von Essen wrote:
Guessing you are running Ubuntu and you have automatic updates on. 

See this thread for different solutions https://github.com/boxcutter/ubuntu/issues/86
On Jul 8, 2017 00:21, "Joanna .Leong" <jkl...@ucdavis.edu> wrote:
correction i mean when executing any package installation like:
                "sudo apt-get install -y swig",


On Friday, July 7, 2017 at 3:08:17 PM UTC-7, Joanna .Leong wrote:
Hi,

I'm running packer and have a shell provisioner executing command "apt-get update" and also tried "sudo apt-get update" and also tried sleeping before executing these commands. Regardless I keep getting the error:

Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
Unable to lock the administration directory (/var/lib/dpkg/)%!(PACKER_COMMA) is another process using it?

No matter how long I sleep I keep seeing this error.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.

Rickard von Essen

unread,
Jul 14, 2017, 12:11:44 AM7/14/17
to packe...@googlegroups.com

Joanna .Leong

unread,
Jul 14, 2017, 4:09:27 PM7/14/17
to Packer
nevermind, got it working; needed to do:
sudo sh -c 'echo "APT::Periodic::Enable "0";" >> /etc/apt/apt.conf.d/10periodic'

Joanna .Leong

unread,
Jul 20, 2017, 2:41:01 PM7/20/17
to Packer
Actually do I need to run a command to have packer restart the VM for my changes to take in effect?

Still I"m getting the following error:
 Reading package lists...
2017-07-20T00:38:23.0415790Z 1500511103,,ui,message,    prod: E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
2017-07-20T00:38:23.0467600Z 1500511103,,ui,message,    prod: E: Unable to lock the administration directory (/var/lib/dpkg/)%!(PACKER_COMMA) is another process using it?

Rickard von Essen

unread,
Jul 20, 2017, 3:01:30 PM7/20/17
to packe...@googlegroups.com
No, or that depends in what you did. If there already are a process
holding this lock you need to shut it down gracefully.
> https://groups.google.com/d/msgid/packer-tool/76b0aa9b-1c1c-4c7c-b30e-289dcb62d423%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages