Docker 在 Ubuntu 19.10 上安装失败

Docker 在 Ubuntu 19.10 上安装失败

我曾经在 Ubuntu Server 19.10 上安装过旧版本的 docker,它运行得很好。我删除了这个旧的 docker 安装,并尝试使用https://docs.docker.com/engine/install/ubuntu/

当 containerd 服务无法启动时,安装会失败。尝试启动 containerd 时,会出现以下错误:

/usr/bin/containerd: symbol lookup error: /usr/bin/containerd: undefined symbol: seccomp_api_set

这是安装过程中的错误:

    invoke-rc.d: initscript docker, action "start" failed.
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Thu 2020-05-07 08:37:28 EDT; 15ms ago
     Docs: https://docs.docker.com
  Process: 17336 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=killed, signal=TERM)
 Main PID: 17336 (code=killed, signal=TERM)

May 07 08:37:28 teddy-server systemd[1]: Starting Docker Application Container Engine...
May 07 08:37:28 teddy-server systemd[1]: docker.service: Main process exited, code=killed, status=15/TERM
May 07 08:37:28 teddy-server systemd[1]: docker.service: Succeeded.
May 07 08:37:28 teddy-server systemd[1]: Stopped Docker Application Container Engine.
dpkg: error processing package docker-ce (--configure):
 installed docker-ce package post-installation script subprocess returned error exit status 1
Processing triggers for systemd (242-7ubuntu3.7) ...
Processing triggers for man-db (2.8.7-3) ...
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for libc-bin (2.30-0ubuntu2.1) ...
Errors were encountered while processing:
 docker-ce
E: Sub-process /usr/bin/dpkg returned an error code (1)

以及 journalctl -xe:

Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit containerd.service has finished successfully.
-- 
-- The job identifier is 34974.
May 07 08:37:28 teddy-server systemd[1]: Listening on Docker Socket for the API.
-- Subject: A start job for unit docker.socket has finished successfully
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit docker.socket has finished successfully.
-- 
-- The job identifier is 34894.
May 07 08:37:28 teddy-server systemd[1]: Starting Docker Application Container Engine...
-- Subject: A start job for unit docker.service has begun execution
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit docker.service has begun execution.
-- 
-- The job identifier is 34891.
May 07 08:37:28 teddy-server containerd[17335]: /usr/bin/containerd: symbol lookup error: /usr/bin/containerd: undefined symbol: seccomp_api_set
May 07 08:37:28 teddy-server systemd[1]: containerd.service: Main process exited, code=exited, status=127/n/a
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- An ExecStart= process belonging to unit containerd.service has exited.
-- 
-- The process' exit code is 'exited' and its exit status is 127.
May 07 08:37:28 teddy-server systemd[1]: containerd.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- The unit containerd.service has entered the 'failed' state with result 'exit-code'.
May 07 08:37:28 teddy-server systemd[1]: docker.service: Main process exited, code=killed, status=15/TERM
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- An ExecStart= process belonging to unit docker.service has exited.
-- 
-- The process' exit code is 'killed' and its exit status is 15.
May 07 08:37:28 teddy-server systemd[1]: docker.service: Succeeded.
-- Subject: Unit succeeded
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- The unit docker.service has successfully entered the 'dead' state.
May 07 08:37:28 teddy-server systemd[1]: Stopped Docker Application Container Engine.
-- Subject: A stop job for unit docker.service has finished
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A stop job for unit docker.service has finished.

我被这个问题难住了。请帮忙!

编辑:

ldd /usr/bin/containerd | grep local不返回任何内容。

apt-cache policy libseccomp2返回:

libseccomp2:
  Installed: 2.4.1-0ubuntu0.19.10.3
  Candidate: 2.4.1-0ubuntu0.19.10.3
  Version table:
 *** 2.4.1-0ubuntu0.19.10.3 500
        500 http://archive.ubuntu.com/ubuntu eoan/main amd64 Packages
        100 /var/lib/dpkg/status

apt-cache policy $(dpkg -S /usr/bin/containerd)返回:

containerd.io:
  Installed: 1.2.13-1
  Candidate: 1.2.13-1
  Version table:
 *** 1.2.13-1 500
        500 https://download.docker.com/linux/ubuntu disco/stable amd64 Packages
        100 /var/lib/dpkg/status
     1.2.13-1 500
        500 https://download.docker.com/linux/ubuntu eoan/nightly amd64 Packages
        500 https://download.docker.com/linux/ubuntu eoan/stable amd64 Packages
     1.2.12-1 500
        500 https://download.docker.com/linux/ubuntu eoan/nightly amd64 Packages
     1.2.11-2 500
        500 https://download.docker.com/linux/ubuntu eoan/nightly amd64 Packages
     1.2.11-1 500
        500 https://download.docker.com/linux/ubuntu eoan/nightly amd64 Packages
     1.2.10-3 500
        500 https://download.docker.com/linux/ubuntu disco/stable amd64 Packages
     1.2.10-2 500
        500 https://download.docker.com/linux/ubuntu disco/stable amd64 Packages
     1.2.6-3 500
        500 https://download.docker.com/linux/ubuntu disco/stable amd64 Packages
     1.2.5-1 500
        500 https://download.docker.com/linux/ubuntu disco/stable amd64 Packages
N: Unable to locate package /usr/bin/containerd

dpkg -S /usr/bin/containerd返回:

containerd.io: /usr/bin/containerd

grep -ir docker /etc/apt/ --include="*.list"返回:

/etc/apt/sources.list:deb [arch=amd64] https://download.docker.com/linux/ubuntu eoan stable 
/etc/apt/sources.list:# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu eoan stable

答案1

我终于解决了这个问题。

首先,我使用以下方法搜索 libseccomp 相关目录 sudo find / -name '*libseccomp*'

我发现我安装了旧版本的 libseccomp, /lib/x86_64-linux-gnu/libseccomp.so.2.3.1并且/lib/x86_64-linux-gnu/libseccomp.so.2

我删除了这两个目录并重新启动,然后我就能够使用官方文档成功安装 Docker。

答案2

添加 Docker PGP 密钥:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

配置docker apt存储库:

echo 'deb [arch=amd64] https://download.docker.com/linux/debian buster stable' | sudo tee /etc/apt/sources.list.d/docker.list

更新APT:

sudo apt-get update

如果您安装了旧版本的 Docker,请卸载它们:

sudo apt-get remove docker docker-engine docker.io

安装 Docker:

sudo apt-get install docker-ce

测试:

sudo docker run hello-world

启动Docker:

sudo systemctl start docker

在启动时启用docker:

sudo systemctl enable docker

允许非root用户使用docker:

sudo usermod -aG docker $USER

现在,注销并重新登录

相关内容