I am creating a droplet (nyc1/4vcpu-8gb/ubuntu-20-04-x64) with doctl and, when accessible (ping on ip address followed by nc on ssh port) I send and run the following bash script:
#!/bin/bash apt-get update apt-get install -y apt-transport-https \ curl \ tmux \ zsh \ zip \ inotify-tools
But for some reason there is some kind of race condition between the apt-update and apt-install because the lock file (/var/lib/dpkg/lock-frontend) seems not to be released, like the following snippet:
Get:29 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 Packages [2,568 B] Get:30 http://archive.ubuntu.com/ubuntu focal-backports/main Translation-en [1,120 B] Get:31 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 c-n-f Metadata [400 B] Get:32 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [5,800 B] Get:33 http://archive.ubuntu.com/ubuntu focal-backports/universe Translation-en [2,068 B] Get:34 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 c-n-f Metadata [288 B] Fetched 5,354 kB in 2s (2,995 kB/s) Reading package lists... Done E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 2194 (apt-get) N: Be aware that removing the lock file is not a solution and may break your system. E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
Am I doing something wrong or maybe is it a bug?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Click below to sign up and get $100 of credit to try our products over 60 days!