当前位置:   article > 正文

Docker 入门到实战 之 Docker安装_loaded plugins: fastestmirror loading mirror speed

loaded plugins: fastestmirror loading mirror speeds from cached hostfile no

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

1、卸载系统残留的docker

  1. [root@Roker ~]# yum remove docker
  2. Loaded plugins: fastestmirror
  3. No Match for argument: docker
  4. No Packages marked for removal

2、安装Docker的版本库

  1. [root@Roker ~]# yum install -y yum-utils
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. Resolving Dependencies
  5. --> Running transaction check
  6. ---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be installed
  7. --> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-54.el7_8.noarch
  8. --> Processing Dependency: libxml2-python for package: yum-utils-1.1.31-54.el7_8.noarch
  9. --> Running transaction check
  10. ---> Package libxml2-python.x86_64 0:2.9.1-6.el7.4 will be installed
  11. ---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed
  12. --> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch
  13. --> Running transaction check
  14. ---> Package python-chardet.noarch 0:2.2.1-3.el7 will be installed
  15. --> Finished Dependency Resolution
  16. Dependencies Resolved
  17. =================================================================================================================================================================================================================
  18. Package Arch Version Repository Size
  19. =================================================================================================================================================================================================================
  20. Installing:
  21. yum-utils noarch 1.1.31-54.el7_8 updates 122 k
  22. Installing for dependencies:
  23. libxml2-python x86_64 2.9.1-6.el7.4 base 247 k
  24. python-chardet noarch 2.2.1-3.el7 base 227 k
  25. python-kitchen noarch 1.1.1-5.el7 base 267 k
  26. Transaction Summary
  27. =================================================================================================================================================================================================================
  28. Install 1 Package (+3 Dependent packages)
  29. Total download size: 862 k
  30. Installed size: 4.3 M
  31. Downloading packages:
  32. (1/4): libxml2-python-2.9.1-6.el7.4.x86_64.rpm | 247 kB 00:00:00
  33. (2/4): python-chardet-2.2.1-3.el7.noarch.rpm | 227 kB 00:00:00
  34. (3/4): python-kitchen-1.1.1-5.el7.noarch.rpm | 267 kB 00:00:00
  35. (4/4): yum-utils-1.1.31-54.el7_8.noarch.rpm | 122 kB 00:00:00
  36. -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  37. Total 1.9 MB/s | 862 kB 00:00:00
  38. Running transaction check
  39. Running transaction test
  40. Transaction test succeeded
  41. Running transaction
  42. Installing : python-chardet-2.2.1-3.el7.noarch 1/4
  43. Installing : python-kitchen-1.1.1-5.el7.noarch 2/4
  44. Installing : libxml2-python-2.9.1-6.el7.4.x86_64 3/4
  45. Installing : yum-utils-1.1.31-54.el7_8.noarch 4/4
  46. Verifying : libxml2-python-2.9.1-6.el7.4.x86_64 1/4
  47. Verifying : python-kitchen-1.1.1-5.el7.noarch 2/4
  48. Verifying : yum-utils-1.1.31-54.el7_8.noarch 3/4
  49. Verifying : python-chardet-2.2.1-3.el7.noarch 4/4
  50. Installed:
  51. yum-utils.noarch 0:1.1.31-54.el7_8
  52. Dependency Installed:
  53. 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
  54. Complete!

  1. [root@Roker ~]# yum-config-manager
  2. Loaded plugins: fastestmirror
  3. ==================================== main ===================================
  4. [main]
  5. alwaysprompt = True
  6. assumeno = False
  7. assumeyes = False
  8. ... ...
  9. ================================= repo: base ================================
  10. [base]
  11. async = True
  12. bandwidth = 0
  13. base_persistdir = /var/lib/yum/repos/x86_64/7
  14. ... ...
  15. ================================= repo: epel ================================
  16. [epel]
  17. async = True
  18. bandwidth = 0
  19. base_persistdir = /var/lib/yum/repos/x86_64/7
  20. ... ...
  21. ================================= repo: extras ==============================
  22. [extras]
  23. async = True
  24. bandwidth = 0
  25. base_persistdir = /var/lib/yum/repos/x86_64/7
  26. ... ...
  27. ================================= repo: updates =============================
  28. [extras]
  29. async = True
  30. bandwidth = 0
  31. base_persistdir = /var/lib/yum/repos/x86_64/7
  32. ... ...
  33. throttle = 0
  34. timeout = 30.0
  35. ui_id = updates/7/x86_64
  36. ui_repoid_vars = releasever,
  37. basearch
  38. username =

3、安装docker-ce

  1. [root@Roker ~]# yum install docker ce
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. No package ce available.
  5. Resolving Dependencies
  6. --> Running transaction check
  7. ---> Package docker.x86_64 2:1.13.1-161.git64e9980.el7_8 will be installed
  8. --> 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
  9. --> 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
  10. --> Processing Dependency: subscription-manager-rhsm-certificates for package: 2:docker-1.13.1-161.git64e9980.el7_8.x86_64
  11. --> Running transaction check
  12. ---> Package docker-client.x86_64 2:1.13.1-161.git64e9980.el7_8 will be installed
  13. ---> Package docker-common.x86_64 2:1.13.1-161.git64e9980.el7_8 will be installed
  14. --> Processing Dependency: skopeo-containers >= 1:0.1.26-2 for package: 2:docker-common-1.13.1-161.git64e9980.el7_8.x86_64
  15. --> Processing Dependency: oci-umount >= 2:2.3.3-3 for package: 2:docker-common-1.13.1-161.git64e9980.el7_8.x86_64
  16. --> Processing Dependency: oci-systemd-hook >= 1:0.1.4-9 for package: 2:docker-common-1.13.1-161.git64e9980.el7_8.x86_64
  17. --> Processing Dependency: oci-register-machine >= 1:0-5.13 for package: 2:docker-common-1.13.1-161.git64e9980.el7_8.x86_64
  18. --> Processing Dependency: lvm2 >= 2.02.112 for package: 2:docker-common-1.13.1-161.git64e9980.el7_8.x86_64
  19. --> Processing Dependency: container-storage-setup >= 0.9.0-1 for package: 2:docker-common-1.13.1-161.git64e9980.el7_8.x86_64
  20. --> Processing Dependency: container-selinux >= 2:2.51-1 for package: 2:docker-common-1.13.1-161.git64e9980.el7_8.x86_64
  21. --> Processing Dependency: atomic-registries for package: 2:docker-common-1.13.1-161.git64e9980.el7_8.x86_64
  22. ---> Package subscription-manager-rhsm-certificates.x86_64 0:1.24.26-3.el7.centos will be
  23. ... ...
  24. installed
  25. Dependency Installed:
  26. 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
  27. 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
  28. 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
  29. 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
  30. 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
  31. 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
  32. 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
  33. 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
  34. 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
  35. 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
  36. 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
  37. 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
  38. 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
  39. 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
  40. usermode.x86_64 0:1.111-6.el7 yajl.x86_64 0:2.0.4-4.el7
  41. Complete!

4、验证安装状态

  1. [root@Roker ~]# docker -v
  2. Docker version 1.13.1, build 64e9980/1.13.1

5、查看当前Docker的状态

  1. [root@Roker ~]# systemctl status docker
  2. Unit docekr.service could not be found.
  3. [root@iZ8vbdmp7p7nu6o38oalgoZ ~]# systemctl status docker
  4. ● docker.service - Docker Application Container Engine
  5. Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
  6. Active: inactive (dead)
  7. Docs: http://docs.docker.com

6、启动Docker

  1. [root@Roker ~]# systemctl start docker
  2. [root@Roker ~]#

# 开机自启 systemctl enable docker 

7、验证是否启动成功

  1. [root@Roker ~]# systemctl status docker
  2. ● docker.service - Docker Application Container Engine
  3. Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
  4. Active: active (running) since Fri 2020-07-03 15:27:48 CST; 6s ago
  5. Docs: http://docs.docker.com
  6. Main PID: 14440 (dockerd-current)
  7. CGroup: /system.slice/docker.service
  8. ├─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/...
  9. └─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...
  10. 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"
  11. 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"
  12. Jul 03 15:27:47 iZ8vbdmp7p7nu6o38oalgoZ dockerd-current[14440]: time="2020-07-03T15:27:47.541545766+08:00" level=info msg="Loading containers: start."
  13. Jul 03 15:27:47 iZ8vbdmp7p7nu6o38oalgoZ dockerd-current[14440]: time="2020-07-03T15:27:47.702976974+08:00" level=info msg="Firewalld running: false"
  14. 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"
  15. Jul 03 15:27:48 iZ8vbdmp7p7nu6o38oalgoZ dockerd-current[14440]: time="2020-07-03T15:27:48.527315047+08:00" level=info msg="Loading containers: done."
  16. 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"
  17. 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
  18. Jul 03 15:27:48 iZ8vbdmp7p7nu6o38oalgoZ systemd[1]: Started Docker Application Container Engine.
  19. 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"
  20. Hint: Some lines were ellipsized, use -l to show in full.

OK,至此,docker在Linux上的安装就结束了。另附docker其他基础操作命令,如下

  • # docker info

查看docker系统信息,也可用来检查docker是否启动成功。

  1. [root@Roker ~]# docker info
  2. Containers: 0
  3. Running: 0
  4. Paused: 0
  5. Stopped: 0
  6. Images: 0
  7. Server Version: 1.13.1
  8. Storage Driver: overlay2
  9. Backing Filesystem: extfs
  10. Supports d_type: true
  11. Native Overlay Diff: true
  12. Logging Driver: journald
  13. Cgroup Driver: systemd
  14. Plugins:
  15. Volume: local
  16. Network: bridge host macvlan null overlay
  17. Swarm: inactive
  18. Runtimes: docker-runc runc
  19. Default Runtime: docker-runc
  20. Init Binary: /usr/libexec/docker/docker-init-current
  21. containerd version: (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
  22. runc version: 66aedde759f33c190954815fb765eedc1d782dd9 (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
  23. init version: fec3683b971d9c3ef73f284f176672c44b448662 (expected: 949e6facb77383876aeff8a6944dde66b3089574)
  24. Security Options:
  25. seccomp
  26. WARNING: You're not using the default seccomp profile
  27. Profile: /etc/docker/seccomp.json
  28. Kernel Version: 3.10.0-957.21.3.el7.x86_64
  29. Operating System: CentOS Linux 7 (Core)
  30. OSType: linux
  31. Architecture: x86_64
  32. Number of Docker Hooks: 3
  33. CPUs: 1
  34. Total Memory: 1.795 GiB
  35. Name: iZ8vbdmp7p7nu6o38oalgoZ
  36. ID: UK4V:EWD6:Z7MO:24I7:JOWB:M4Q2:42QV:RP42:PVAT:NBF4:CIVY:4RT7
  37. Docker Root Dir: /var/lib/docker
  38. Debug Mode (client): false
  39. Debug Mode (server): false
  40. Registry: https://index.docker.io/v1/
  41. WARNING: bridge-nf-call-iptables is disabled
  42. WARNING: bridge-nf-call-ip6tables is disabled
  43. Experimental: false
  44. Insecure Registries:
  45. 127.0.0.0/8
  46. Live Restore Enabled: false
  47. Registries: docker.io (secure)

Docker命令 

  1. 容器生命周期管理 — docker [run|start|stop|restart|kill|rm|pause|unpause]
  2. 容器操作运维 — docker [ps|inspect|top|attach|exec|events|logs|wait|export|import|port]
  3. 容器rootfs命令 — docker [commit|cp|diff]
  4. 镜像仓库 — docker [login|pull|push|search]
  5. 本地镜像管理 — docker [images|rmi|tag|build|history|save|import]
  6. 其他命令 — docker [info|version]


参考:

https://blog.csdn.net/wjyyhhxit/article/details/83582588

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小舞很执着/article/detail/823272
推荐阅读
相关标签
  

闽ICP备14008679号