LoginSignup
2
0

More than 1 year has passed since last update.

Could not get lock /var/lib/dpkg/lock-frontend (Ubuntu20.04)

Last updated at Posted at 2022-01-02

Docker インストールしようとしたらエラー。


$ sudo curl -sSL https://get.docker.com/ | CHANNEL=stable sh
# Executing docker install script, commit: 93d2499759296ac1f9c510605fef85052a2c32be
Warning: the "docker" command appears to already exist on this system.

If you already have Docker installed, this script can cause trouble, which is
why we're displaying this warning and provide the opportunity to cancel the
installation.

If you installed the current Docker package using this script and are using it
again to update Docker, you can safely ignore this message.

You may press Ctrl+C now to abort this script.
+ sleep 20
+ sudo -E sh -c apt-get update -qq >/dev/null
+ sudo -E sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 4240 (unattended-upgr)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?


プロセス4240は何かな?


$ ps -auxww | grep 4240
colord      2202  0.0  0.3 247564 14240 ?        Ssl  01:02   0:00 /usr/libexec/colord
root        4240 14.2  3.1 346872 121712 ?       Sl   01:05   1:22 /usr/bin/python3 /usr/bin/unattended-upgrade
nanbuwks   25948  0.0  0.0  10092   736 pts/0    S+   01:15   0:00 grep --color=auto 4240

unattended-upgrade だ。 自動アップグレードのプログラムらしい。
ということは、Docker のインストールの問題ではなく apt の問題ということだな。

$ sudo apt-get upgrade
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 4240 (unattended-upgr)
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?

たしかにそうでした。Ubuntu のインストール後の設定で、うっかり自動アップグレードを設定してしまったっぽい。
MS-Windows の Upgrade のシチュエーションと同様になってしまってとんでもない。イザという時に干渉しないように、切っておこう。


$  cat /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

これを両方 0 に書き換えて再起動で apt コマンドおよび docker のインストール両方問題なく実行できました。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0