赞
踩
Docker 分为 CE 和 EE 两大版本。CE 即社区版(免费,支持周期 7 个月),EE 即企业版,强调安全,付费使用,支持周期 24 个月。
Docker CE 分为 Stable、test 和 nightly 三个更新频道。
官方网站上有各种环境下的 安装指南。
本教程以 CentOS 7.x
为例,配置并运行 Docker
,其他 Linux 发行版大同小异。
其他系统安装教程请参阅 ==> https://www.runoob.com/docker/ubuntu-docker-install.html
- [root@Roker ~]# yum remove docker
- Loaded plugins: fastestmirror
- No Match for argument: docker
- No Packages marked for removal
- [root@Roker ~]# yum install -y yum-utils
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- Resolving Dependencies
- --> Running transaction check
- ---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be installed
- --> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-54.el7_8.noarch
- --> Processing Dependency: libxml2-python for package: yum-utils-1.1.31-54.el7_8.noarch
- --> Running transaction check
- ---> Package libxml2-python.x86_64 0:2.9.1-6.el7.4 will be installed
- ---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed
- --> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch
- --> Running transaction check
- ---> Package python-chardet.noarch 0:2.2.1-3.el7 will be installed
- --> Finished Dependency Resolution
-
- Dependencies Resolved
-
- =================================================================================================================================================================================================================
- Package Arch Version Repository Size
- =================================================================================================================================================================================================================
- Installing:
- yum-utils noarch 1.1.31-54.el7_8 updates 122 k
- Installing for dependencies:
- libxml2-python x86_64 2.9.1-6.el7.4 base 247 k
- python-chardet noarch 2.2.1-3.el7 base 227 k
- python-kitchen noarch 1.1.1-5.el7 base 267 k
-
- Transaction Summary
- =================================================================================================================================================================================================================
- Install 1 Package (+3 Dependent packages)
-
- Total download size: 862 k
- Installed size: 4.3 M
- Downloading packages:
- (1/4): libxml2-python-2.9.1-6.el7.4.x86_64.rpm | 247 kB 00:00:00
- (2/4): python-chardet-2.2.1-3.el7.noarch.rpm | 227 kB 00:00:00
- (3/4): python-kitchen-1.1.1-5.el7.noarch.rpm | 267 kB 00:00:00
- (4/4): yum-utils-1.1.31-54.el7_8.noarch.rpm | 122 kB 00:00:00
- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Total 1.9 MB/s | 862 kB 00:00:00
- Running transaction check
- Running transaction test
- Transaction test succeeded
- Running transaction
- Installing : python-chardet-2.2.1-3.el7.noarch 1/4
- Installing : python-kitchen-1.1.1-5.el7.noarch 2/4
- Installing : libxml2-python-2.9.1-6.el7.4.x86_64 3/4
- Installing : yum-utils-1.1.31-54.el7_8.noarch 4/4
- Verifying : libxml2-python-2.9.1-6.el7.4.x86_64 1/4
- Verifying : python-kitchen-1.1.1-5.el7.noarch 2/4
- Verifying : yum-utils-1.1.31-54.el7_8.noarch 3/4
- Verifying : python-chardet-2.2.1-3.el7.noarch 4/4
-
- Installed:
- yum-utils.noarch 0:1.1.31-54.el7_8
-
- Dependency Installed:
- libxml2-python.x86_64 0:2.9.1-6.el7.4 python-chardet.noarch 0:2.2.1-3.el7 python-kitchen.noarch 0:1.1.1-5.el7
-
- Complete!
- [root@Roker ~]# yum-config-manager
- Loaded plugins: fastestmirror
- ==================================== main ===================================
- [main]
- alwaysprompt = True
- assumeno = False
- assumeyes = False
-
- ... ...
-
- ================================= repo: base ================================
- [base]
- async = True
- bandwidth = 0
- base_persistdir = /var/lib/yum/repos/x86_64/7
-
- ... ...
-
- ================================= repo: epel ================================
- [epel]
- async = True
- bandwidth = 0
- base_persistdir = /var/lib/yum/repos/x86_64/7
-
- ... ...
-
- ================================= repo: extras ==============================
- [extras]
- async = True
- bandwidth = 0
- base_persistdir = /var/lib/yum/repos/x86_64/7
-
- ... ...
-
- ================================= repo: updates =============================
- [extras]
- async = True
- bandwidth = 0
- base_persistdir = /var/lib/yum/repos/x86_64/7
-
- ... ...
-
-
- throttle = 0
- timeout = 30.0
- ui_id = updates/7/x86_64
- ui_repoid_vars = releasever,
- basearch
- username =
- [root@Roker ~]# yum install docker ce
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- No package ce available.
- Resolving Dependencies
- --> Running transaction check
- ---> Package docker.x86_64 2:1.13.1-161.git64e9980.el7_8 will be installed
- --> Processing Dependency: docker-common = 2:1.13.1-161.git64e9980.el7_8 for package: 2:docker-1.13.1-161.git64e9980.el7_8.x86_64
- --> Processing Dependency: docker-client = 2:1.13.1-161.git64e9980.el7_8 for package: 2:docker-1.13.1-161.git64e9980.el7_8.x86_64
- --> Processing Dependency: subscription-manager-rhsm-certificates for package: 2:docker-1.13.1-161.git64e9980.el7_8.x86_64
- --> Running transaction check
- ---> Package docker-client.x86_64 2:1.13.1-161.git64e9980.el7_8 will be installed
- ---> Package docker-common.x86_64 2:1.13.1-161.git64e9980.el7_8 will be installed
- --> Processing Dependency: skopeo-containers >= 1:0.1.26-2 for package: 2:docker-common-1.13.1-161.git64e9980.el7_8.x86_64
- --> Processing Dependency: oci-umount >= 2:2.3.3-3 for package: 2:docker-common-1.13.1-161.git64e9980.el7_8.x86_64
- --> Processing Dependency: oci-systemd-hook >= 1:0.1.4-9 for package: 2:docker-common-1.13.1-161.git64e9980.el7_8.x86_64
- --> Processing Dependency: oci-register-machine >= 1:0-5.13 for package: 2:docker-common-1.13.1-161.git64e9980.el7_8.x86_64
- --> Processing Dependency: lvm2 >= 2.02.112 for package: 2:docker-common-1.13.1-161.git64e9980.el7_8.x86_64
- --> Processing Dependency: container-storage-setup >= 0.9.0-1 for package: 2:docker-common-1.13.1-161.git64e9980.el7_8.x86_64
- --> Processing Dependency: container-selinux >= 2:2.51-1 for package: 2:docker-common-1.13.1-161.git64e9980.el7_8.x86_64
- --> Processing Dependency: atomic-registries for package: 2:docker-common-1.13.1-161.git64e9980.el7_8.x86_64
- ---> Package subscription-manager-rhsm-certificates.x86_64 0:1.24.26-3.el7.centos will be
-
- ... ...
-
- installed
- Dependency Installed:
- PyYAML.x86_64 0:3.10-11.el7 atomic-registries.x86_64 1:1.22.1-33.gitb507039.el7_8 audit-libs-python.x86_64 0:2.8.5-4.el7
- checkpolicy.x86_64 0:2.5-8.el7 container-selinux.noarch 2:2.119.1-1.c57a6f9.el7 container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7
- containers-common.x86_64 1:0.1.40-7.el7_8 device-mapper-event.x86_64 7:1.02.164-7.el7_8.2 device-mapper-event-libs.x86_64 7:1.02.164-7.el7_8.2
- device-mapper-persistent-data.x86_64 0:0.8.5-2.el7 docker-client.x86_64 2:1.13.1-161.git64e9980.el7_8 docker-common.x86_64 2:1.13.1-161.git64e9980.el7_8
- fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 fuse3-libs.x86_64 0:3.6.1-4.el7 libaio.x86_64 0:0.3.109-13.el7
- libcgroup.x86_64 0:0.41-21.el7 libnl.x86_64 0:1.1.4-3.el7 libsemanage-python.x86_64 0:2.5-14.el7
- libyaml.x86_64 0:0.1.4-11.el7_0 lvm2.x86_64 7:2.02.186-7.el7_8.2 lvm2-libs.x86_64 7:2.02.186-7.el7_8.2
- oci-register-machine.x86_64 1:0-6.git2b44233.el7 oci-systemd-hook.x86_64 1:0.2.0-1.git05e6923.el7_6 oci-umount.x86_64 2:2.5-3.el7
- policycoreutils-python.x86_64 0:2.5-34.el7 python-IPy.noarch 0:0.75-6.el7 python-backports.x86_64 0:1.0-8.el7
- python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 python-dateutil.noarch 0:1.5-7.el7 python-dmidecode.x86_64 0:3.12.2-4.el7
- python-ethtool.x86_64 0:0.8-8.el7 python-inotify.noarch 0:0.9.4-4.el7 python-ipaddress.noarch 0:1.0.16-2.el7
- python-pytoml.noarch 0:0.1.14-1.git7dea353.el7 python-setuptools.noarch 0:0.9.8-7.el7 python-six.noarch 0:1.9.0-2.el7
- python-syspurpose.x86_64 0:1.24.26-3.el7.centos setools-libs.x86_64 0:3.3.8-4.el7 slirp4netns.x86_64 0:0.4.3-4.el7_8
- subscription-manager.x86_64 0:1.24.26-3.el7.centos subscription-manager-rhsm.x86_64 0:1.24.26-3.el7.centos subscription-manager-rhsm-certificates.x86_64 0:1.24.26-3.el7.centos
- usermode.x86_64 0:1.111-6.el7 yajl.x86_64 0:2.0.4-4.el7
-
- Complete!
- [root@Roker ~]# docker -v
- Docker version 1.13.1, build 64e9980/1.13.1
- [root@Roker ~]# systemctl status docker
- Unit docekr.service could not be found.
- [root@iZ8vbdmp7p7nu6o38oalgoZ ~]# systemctl status docker
- ● docker.service - Docker Application Container Engine
- Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
- Active: inactive (dead)
- Docs: http://docs.docker.com
- [root@Roker ~]# systemctl start docker
- [root@Roker ~]#
# 开机自启 systemctl enable docker
- [root@Roker ~]# systemctl status docker
- ● docker.service - Docker Application Container Engine
- Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
- Active: active (running) since Fri 2020-07-03 15:27:48 CST; 6s ago
- Docs: http://docs.docker.com
- Main PID: 14440 (dockerd-current)
- CGroup: /system.slice/docker.service
- ├─14440 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/...
- └─14445 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/contain...
-
- Jul 03 15:27:47 iZ8vbdmp7p7nu6o38oalgoZ dockerd-current[14440]: time="2020-07-03T15:27:47.327252104+08:00" level=warning msg="Docker could not enable SELinux on the host system"
- Jul 03 15:27:47 iZ8vbdmp7p7nu6o38oalgoZ dockerd-current[14440]: time="2020-07-03T15:27:47.540891085+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
- Jul 03 15:27:47 iZ8vbdmp7p7nu6o38oalgoZ dockerd-current[14440]: time="2020-07-03T15:27:47.541545766+08:00" level=info msg="Loading containers: start."
- Jul 03 15:27:47 iZ8vbdmp7p7nu6o38oalgoZ dockerd-current[14440]: time="2020-07-03T15:27:47.702976974+08:00" level=info msg="Firewalld running: false"
- Jul 03 15:27:48 iZ8vbdmp7p7nu6o38oalgoZ dockerd-current[14440]: time="2020-07-03T15:27:48.277305467+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. ... IP address"
- Jul 03 15:27:48 iZ8vbdmp7p7nu6o38oalgoZ dockerd-current[14440]: time="2020-07-03T15:27:48.527315047+08:00" level=info msg="Loading containers: done."
- Jul 03 15:27:48 iZ8vbdmp7p7nu6o38oalgoZ dockerd-current[14440]: time="2020-07-03T15:27:48.574294710+08:00" level=info msg="Daemon has completed initialization"
- Jul 03 15:27:48 iZ8vbdmp7p7nu6o38oalgoZ dockerd-current[14440]: time="2020-07-03T15:27:48.574331855+08:00" level=info msg="Docker daemon" commit="64e9980/1.13.1" graphdriver=overlay2 version=1.13.1
- Jul 03 15:27:48 iZ8vbdmp7p7nu6o38oalgoZ systemd[1]: Started Docker Application Container Engine.
- Jul 03 15:27:48 iZ8vbdmp7p7nu6o38oalgoZ dockerd-current[14440]: time="2020-07-03T15:27:48.579866717+08:00" level=info msg="API listen on /var/run/docker.sock"
- Hint: Some lines were ellipsized, use -l to show in full.
查看docker系统信息,也可用来检查docker是否启动成功。
- [root@Roker ~]# docker info
- Containers: 0
- Running: 0
- Paused: 0
- Stopped: 0
- Images: 0
- Server Version: 1.13.1
- Storage Driver: overlay2
- Backing Filesystem: extfs
- Supports d_type: true
- Native Overlay Diff: true
- Logging Driver: journald
- Cgroup Driver: systemd
- Plugins:
- Volume: local
- Network: bridge host macvlan null overlay
- Swarm: inactive
- Runtimes: docker-runc runc
- Default Runtime: docker-runc
- Init Binary: /usr/libexec/docker/docker-init-current
- containerd version: (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
- runc version: 66aedde759f33c190954815fb765eedc1d782dd9 (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
- init version: fec3683b971d9c3ef73f284f176672c44b448662 (expected: 949e6facb77383876aeff8a6944dde66b3089574)
- Security Options:
- seccomp
- WARNING: You're not using the default seccomp profile
- Profile: /etc/docker/seccomp.json
- Kernel Version: 3.10.0-957.21.3.el7.x86_64
- Operating System: CentOS Linux 7 (Core)
- OSType: linux
- Architecture: x86_64
- Number of Docker Hooks: 3
- CPUs: 1
- Total Memory: 1.795 GiB
- Name: iZ8vbdmp7p7nu6o38oalgoZ
- ID: UK4V:EWD6:Z7MO:24I7:JOWB:M4Q2:42QV:RP42:PVAT:NBF4:CIVY:4RT7
- Docker Root Dir: /var/lib/docker
- Debug Mode (client): false
- Debug Mode (server): false
- Registry: https://index.docker.io/v1/
- WARNING: bridge-nf-call-iptables is disabled
- WARNING: bridge-nf-call-ip6tables is disabled
- Experimental: false
- Insecure Registries:
- 127.0.0.0/8
- Live Restore Enabled: false
- Registries: docker.io (secure)
- 容器生命周期管理 — docker [run|start|stop|restart|kill|rm|pause|unpause]
- 容器操作运维 — docker [ps|inspect|top|attach|exec|events|logs|wait|export|import|port]
- 容器rootfs命令 — docker [commit|cp|diff]
- 镜像仓库 — docker [login|pull|push|search]
- 本地镜像管理 — docker [images|rmi|tag|build|history|save|import]
- 其他命令 — docker [info|version]
参考:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。