【Centos 8】【Centos 7】腾讯云服务器 安装 docker
前言CentOS Linux release 8.2CentOS Linux release 7.9yum源腾讯云服务器Centos 8、Centos 7版本上的yum中包含了docker,无需配置yum源。安装 docker查看dockershell> yum info dockerLoaded plugins: fastestmirror, langpacksLoading mirror
·
前言
- CentOS Linux release 8.2
- CentOS Linux release 7.9
yum源
腾讯云服务器Centos 8、Centos 7版本上的yum中包含了docker,无需配置yum源。
安装 docker
- 查看docker
shell> yum info docker
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Available Packages
Name : docker
Arch : x86_64
Epoch : 2
Version : 1.13.1
Release : 208.git7d71120.el7_9
Size : 17 M
Repo : extras/7/x86_64
Summary : Automates deployment of containerized applications
URL : https://github.com/docker/docker
License : ASL 2.0
Description : Docker is an open-source engine that automates the deployment of any
: application as a lightweight, portable, self-sufficient container that will
: run virtually anywhere.
:
: Docker containers can encapsulate any payload, and will run consistently on
: and between virtually any server. The same container that a developer builds
: and tests on a laptop will run at scale, in production*, on VMs, bare-metal
: servers, OpenStack clusters, public instances, or combinations of the above.
- 安装daocker
shell> yum install -y docker
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
os | 3.6 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/3): epel/7/x86_64/updateinfo | 1.0 MB 00:00:00
(2/3): epel/7/x86_64/primary_db | 7.0 MB 00:00:01
(3/3): updates/7/x86_64/primary_db | 12 MB 00:00:01
Resolving Dependencies
--> Running transaction check
---> Package docker.x86_64 2:1.13.1-208.git7d71120.el7_9 will be installed
--> Processing Dependency: docker-common = 2:1.13.1-208.git7d71120.el7_9 for package: 2:docker-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: docker-client = 2:1.13.1-208.git7d71120.el7_9 for package: 2:docker-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: subscription-manager-rhsm-certificates for package: 2:docker-1.13.1-208.git7d71120.el7_9.x86_64
...(省略)
Installed:
docker.x86_64 2:1.13.1-208.git7d71120.el7_9
Dependency Installed:
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.2-1.911c772.el7_8 container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7 containers-common.x86_64 1:0.1.40-11.el7_8
docker-client.x86_64 2:1.13.1-208.git7d71120.el7_9 docker-common.x86_64 2:1.13.1-208.git7d71120.el7_9 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8
fuse3-libs.x86_64 0:3.6.1-4.el7 libcgroup.x86_64 0:0.41-21.el7 libsemanage-python.x86_64 0:2.5-14.el7
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-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-pytoml.noarch 0:0.1.14-1.git7dea353.el7 python-syspurpose.x86_64 0:1.24.48-1.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.48-1.el7.centos subscription-manager-rhsm.x86_64 0:1.24.48-1.el7.centos
subscription-manager-rhsm-certificates.x86_64 0:1.24.48-1.el7.centos
Complete!
- 查看已安装的 docker 的版本
shell> docker version
Client:
Version: 1.13.1
API version: 1.26
Package version:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
- 启动docker
shell> systemctl start docker
- 查看docker运行状态
shell> 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 Wed 2021-11-17 16:44:59 CST; 20s ago
Docs: http://docs.docker.com
Main PID: 17532 (dockerd-current)
CGroup: /system.slice/docker.service
├─17532 /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/libexec/docker/docker-pr...
└─17540 /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/containerd --shim docker-contai...
Nov 17 16:44:58 VM-16-5-centos dockerd-current[17532]: time="2021-11-17T16:44:58.758139169+08:00" level=warning msg="Docker could not enable SELinux on the host system"
Nov 17 16:44:58 VM-16-5-centos dockerd-current[17532]: time="2021-11-17T16:44:58.804182251+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Nov 17 16:44:58 VM-16-5-centos dockerd-current[17532]: time="2021-11-17T16:44:58.804653182+08:00" level=info msg="Loading containers: start."
Nov 17 16:44:58 VM-16-5-centos dockerd-current[17532]: time="2021-11-17T16:44:58.872826409+08:00" level=info msg="Firewalld running: false"
Nov 17 16:44:58 VM-16-5-centos dockerd-current[17532]: time="2021-11-17T16:44:58.957010199+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be use...red IP address"
Nov 17 16:44:58 VM-16-5-centos dockerd-current[17532]: time="2021-11-17T16:44:58.987554477+08:00" level=info msg="Loading containers: done."
Nov 17 16:44:59 VM-16-5-centos dockerd-current[17532]: time="2021-11-17T16:44:59.031567584+08:00" level=info msg="Daemon has completed initialization"
Nov 17 16:44:59 VM-16-5-centos dockerd-current[17532]: time="2021-11-17T16:44:59.031591129+08:00" level=info msg="Docker daemon" commit="7d71120/1.13.1" graphdriver=overlay2 version=1.13.1
Nov 17 16:44:59 VM-16-5-centos dockerd-current[17532]: time="2021-11-17T16:44:59.035053083+08:00" level=info msg="API listen on /var/run/docker.sock"
Nov 17 16:44:59 VM-16-5-centos systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
- docker 版的 Hello World!
shell> docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ...
latest: Pulling from docker.io/library/hello-world
2db29710123e: Pull complete
Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
Status: Downloaded newer image for docker.io/hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
更多推荐
所有评论(0)