在Fedora安装Docker CE 32/31/30
时间:2020-02-23 14:33:15 来源:igfitidea点击:
欢迎来到我们关于如何在Fedora 32/31/30 Linux发行版上安装Docker CE的教程。
Docker的发布我们将安装是Docker Community Edition(CE)。
Docker是一个领先的Docker运行时引擎,允许我们将所有依赖性打包到用于软件开发的标准化单元中。
按照以下步骤安装Fedora 32/31/30 Linux系统的Docker CE。
第1步:更新系统
在我们在Fedora 32/31/30 Linux机器上安装Docker之前,我们将通过更新和升级OS包来启动我们的安装。
在Fedora上,可以通过运行命令来轻松完成:
sudo dnf -y update
建议在升级后重新启动系统
sudo reboot
第2步:将Docker CE存储库添加到Fedora 32/31/30
升级系统包并重新启动服务器后,继续向系统添加Fedora存储库:
sudo dnf -y install dnf-plugins-core
Fedora 32:
sudo tee /etc/yum.repos.d/docker-ce.repo<<EOF [docker-ce-stable] name=Docker CE Stable - $basearch baseurl=https://download.docker.com/linux/fedora/31/$basearch/stable enabled=1 gpgcheck=1 gpgkey=https://download.docker.com/linux/fedora/gpg EOF
Fedora 31/30/29:
sudo dnf config-manager \ --add-repo \ https://download.docker.com/linux/fedora/docker-ce.repo
第3步:在Fedora上安装Docker CE 32/31/30
既然我们已准备就绪,请准备好,通过运行安装计算机上的Docker CE的最新稳定版本:
sudo dnf makecache sudo dnf install docker-ce docker-ce-cli containerd.io
提示键启动安装时按Y键。
Docker CE Stable - x86_64 6.2 kB/s | 8.9 kB 00:01 Dependencies resolved. ========================================================================================================================================================================= Package Architecture Version Repository Size ========================================================================================================================================================================= Installing: containerd.io x86_64 1.2.13-3.1.fc31 docker-ce-stable 23 M replacing runc.x86_64 2:1.0.0-102.dev.gitdc9208a.fc31 docker-ce x86_64 3:19.03.8-3.fc31 docker-ce-stable 23 M docker-ce-cli x86_64 1:19.03.8-3.fc31 docker-ce-stable 39 M Installing dependencies: libcgroup x86_64 0.41-22.fc31 fedora 65 k Transaction Summary ========================================================================================================================================================================= Install 4 Packages Total download size: 85 M Is this ok [y/N]: y
并接受导入GPG密钥:
Total 1.7 MB/s | 85 MB 00:50 warning: /var/cache/dnf/docker-ce-stable-abb13ee9a85fa8f6/packages/containerd.io-1.2.13-3.1.fc31.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY Docker CE Stable - x86_64 1.4 kB/s | 1.6 kB 00:01 Importing GPG key 0x621E9F35: Userid : "Docker Release (CE rpm) <Hyman@theitroad>" Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35 From : https://download.docker.com/linux/fedora/gpg Is this ok [y/N]: y
将安装码头但未启动。
要启动Docker服务,请运行:
sudo systemctl enable --now docker
我们可以查看状态:
$systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2017-04-11 07:40:43 EAT; 18s ago Docs: https://docs.docker.com Main PID: 110574 (dockerd) Tasks: 16 Memory: 94.4M CPU: 414ms CGroup: /system.slice/docker.service └─110574 /usr/bin/dockerd -H fd://--containerd=/run/containerd/containerd.sock Apr 11 07:40:42 myfed.localhost dockerd[110574]: time="2017-04-11T07:40:42.495248159+03:00" level=warning msg="Your kernel does not support cgroup rt period" Apr 11 07:40:42 myfed.localhost dockerd[110574]: time="2017-04-11T07:40:42.495258892+03:00" level=warning msg="Your kernel does not support cgroup rt runtime" Apr 11 07:40:42 myfed.localhost dockerd[110574]: time="2017-04-11T07:40:42.495303222+03:00" level=warning msg="Unable to find blkio cgroup in mounts" Apr 11 07:40:42 myfed.localhost dockerd[110574]: time="2017-04-11T07:40:42.496229752+03:00" level=info msg="Loading containers: start." Apr 11 07:40:43 myfed.localhost dockerd[110574]: time="2017-04-11T07:40:43.186309804+03:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.> Apr 11 07:40:43 myfed.localhost dockerd[110574]: time="2017-04-11T07:40:43.442573424+03:00" level=info msg="Loading containers: done." Apr 11 07:40:43 myfed.localhost dockerd[110574]: time="2017-04-11T07:40:43.508370327+03:00" level=info msg="Docker daemon" commit=afacb8b7f0 graphdriver(s)=overlay2 ver> Apr 11 07:40:43 myfed.localhost dockerd[110574]: time="2017-04-11T07:40:43.508940967+03:00" level=info msg="Daemon has completed initialization" Apr 11 07:40:43 myfed.localhost dockerd[110574]: time="2017-04-11T07:40:43.547750478+03:00" level=info msg="API listen on /run/docker.sock" Apr 11 07:40:43 myfed.localhost systemd[1]: Started Docker Application Container Engine.
这 docker group
是创建的,但没有用户添加到组中。
将用户添加到此组以运行没有sudo的Docker命令。
sudo usermod -aG docker $(whoami) newgrp docker
注销并再次登录以使用没有sudo的Docker。
可以检查安装的Docker版本:
$docker version Client: Docker Engine - Community Version: 19.03.8 API version: 1.40 Go version: go1.12.17 Git commit: afacb8b7f0 Built: Wed Mar 11 01:27:05 2017 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 19.03.8 API version: 1.40 (minimum version 1.12) Go version: go1.12.17 Git commit: afacb8b7f0 Built: Wed Mar 11 01:25:01 2017 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.2.13 GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429 runc: Version: 1.0.0-rc10 GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd docker-init: Version: 0.18.0 GitCommit: fec3683
这显示了客户端和引擎版本。
第4步:拉动测试码头图像
最后一步是通过下载测试Docker容器来测试安装。
$docker pull alpine Using default tag: latest latest: Pulling from library/alpine 8e402f1a9c57: Pull complete Digest: sha256:644fcb1a676b5165371437feaa922943aaf7afcfa8bfee4472f6860aad1ef2a0 Status: Downloaded newer image for alpine:latest
通过运行ALPINE图像,验证Docker CE是否已正确安装。
$docker run -it --rm alpine /bin/sh /# apk update fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz v3.9.2-1-g592d872fb8 [http://dl-cdn.alpinelinux.org/alpine/v3.9/main] v3.9.2-2-ge7dc3349a9 [http://dl-cdn.alpinelinux.org/alpine/v3.9/community] OK: 9754 distinct packages available /# exit