赞
踩
docker 理论的知识可以看下面这篇文章
Docker快速入门,看这个就够了
本次实验一共有三个任务:
快速安装最新版的 Docker。这一步我们要卸载系统中旧版本的 Docker 然后装上最新版的 Docker 并启动。
运行 Docker 容器。这一步我们要学习如何快速运行一个容器,以及如何通过拉取镜像、创建容器来分步运行容器。
停止和删除 Docker 容器。这一步我们要学习如何停止正在运行的容器,如何删除容器及其镜像。
卸载旧版本的 Docker
列出系统中已安装的docker包:
yum list installed | grep docker
卸载已安装的docker包:
yum -y remove docker-ce-cli.x86_64
yum -y remove docker-ce.x86_64
yum -y remove containerd.io
如果系统中没有 Docker,则直接进入下一步。
安装 Docker 所需的依赖:
yum install -y yum-utils device-mapper-persistent-data lvm2
添加 Docker 的 yum 源:
yum-config-manager --add-repo https://mirrors.cloud.tencent.com/docker-ce/linux/centos/docker-ce.repo
yum安装 Docker(使用yum源 安装 Docker):
yum install -y docker-ce docker-ce-cli containerd.io
验证 Docker 版本以确认安装成功:
docker version
如图所示,Docker 安装成功:
启动 Docker
执行以下命令启动 Docker:
systemctl start docker
然后将 Docker 设置为开机启动:
systemctl enable docker
查看 Docker 运行状态:
service docker status
如图所示,Docker 正在运行:
下面这张图 是我实际操作的截图
创建 Docker 配置目录:
mkdir -p /etc/docker
配置 Docker 镜像加速源:
第一个配置(支持多个yum源)(推荐使用)↓↓↓
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["http://hub-mirror.c.163.com", "https://docker.mirrors.ustc.edu.cn", "https://pee6w651.mirror.aliyuncs.com", "https://registry.docker-cn.com", "https://mirror.ccs.tencentyun.com"]
}
EOF
第二个配置(只支持一个yum源)↓↓↓
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://mirror.ccs.tencentyun.com"]
}
EOF
重启守护进程并重启 Docker:
systemctl daemon-reload && systemctl restart docker
重启完成后,镜像加速即配置成功。
老司机的话到这一步就结束了,小白可以继续参考下面的步骤进行练习_
CentOS7-Docker 配置国内镜像源
https://www.cnblogs.com/reasonzzy/p/11127359.html
以下内容是上面链接里复制的,可以忽略:
创建文件夹
sudo mkdir -p /etc/docker
编辑/etc/docker/daemon.json文件,并输入国内镜像源地址
sudo vi /etc/docker/daemon.json
使用 docker run 命令可以直接拉取镜像并运行一个容器,例如:
docker run --name=hello hello-world
这行命令会直接拉取 hello-world 镜像,然后运行一个 hello 容器,可以通过以下命令查看该容器的进程:
docker ps -a
可以看到 hello 容器已经运行过了:
我们也可以一步一步来运行容器。以 calibre-web 为例,先拉取 Docker 镜像:
docker pull johngong/calibre-web
查看现有的镜像:
docker images
如图所示,calibre-web 镜像拉取成功:
镜像拉取成功后,根据镜像创建容器:
docker create --name=calibre-web -p 80:8083 -v /data/calibre-web/library:/library -e WEBLANGUAGE=zh_CN johngong/calibre-web
其中:
docker create:是创建容器的命令
–name=calibre-web: 表示创建的容器的名称
-p 80:8083: 表示该容器将 80 端口映射到 8083 端口
-v /data/calibre-web/librery:/libray : 表示该容器将 /data/calibre-web/library 目录映射为 /library 目录
-e WEBLANGUAGE=zh_CN: 表示该容器定义了一个变量,变量名是 WEBLANGUAGE,变量值是 zh_CN
johngong/calibre-web: 是容器的镜像,这里也就是我们前面拉取的镜像
使用如下命令可以查看现有的全部容器:
docker ps -a
如图所示,calibre-web 容器创建成功:
与 docker run 不同的是,docker create 创建出来的容器不会直接运行。
可以查看下运行中的容器进程:
docker ps
可以看到,没有任何容器在运行:
使用以下命令启动刚才创建好的容器:
docker start calibre-web
查看容器进程:
docker ps
可以看到,calibre-web 容器正在运行:
要停止正在运行的容器有两种方法。一种是 docker stop,例如:
docker stop calibre-web
使用 docker ps
命令可以看到,正在运行的容器中已经没有 calibre-web 了:
另一种方法是 docker kill,例如:
docker kill calibre-web
这两种方法的区别在于,docker stop 会给时间让容器保存最后的运行状态,而 docker kill 则会直接关闭容器。
使用 docker rm 命令可以删除指定的容器,例如:
docker rm hello
查看所有容器:
docker ps -a
已经看不到 hello 容器了:
我们先重新运行 calibre-web 容器:
docker start calibre-web
这时候我们用 docker rm 删除该容器:
docker rm calibre-web
命令行会报错:
要删除运行状态的容器,需要带上 -f 选项:
docker rm -f calibre-web
正在运行的 calibre-web 会被强制停止并删除。
使用 docker rmi 命令可以删除指定的镜像,例如:
docker rmi hello-world
查看现有镜像:
docker images
已经看不到 hello-world 镜像了:
我们可以通过 docker rmi 跟镜像 ID 来删除指定的镜像。而获取所有镜像 ID 的命令是:
docker images -q
如图所示,命令行列出了剩余所有镜像的 ID:
我们可以用这些 ID 一次性删除所有镜像:
docker rmi `docker images -q`
现在用 docker images
已经看不到镜像了:
恭喜你!你已经完成了本次实验!
下面的资料,供您拓展学习:
1)Docker 搭建 LNMP 环境
2)Docker 官方文档
3)DevOps 实战:Jenkins Docker
.
.
1、firewalld的基本使用
启动: systemctl start firewalld
查看状态: systemctl status firewalld
停止: systemctl disable firewalld
禁用: systemctl stop firewalld
2.systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。
启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed
3.配置firewalld-cmd
查看版本: firewall-cmd --version
查看帮助:firewall-cmd --help
显示状态: firewall-cmd --state
查看所有打开的端口: firewall-cmd --zone=public --list-ports
更新防火墙规则: firewall-cmd --reload
查看区域信息: firewall-cmd --get-active-zones
查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:firewall-cmd --panic-on
取消拒绝状态: firewall-cmd --panic-off
查看是否拒绝: firewall-cmd --query-panic
4.那怎么开启一个端口呢
添加:firewall-cmd --zone=public --add-port=80/tcp --permanent
(–permanent永久生效,没有此参数重启后失效)
重新载入:firewall-cmd --reload
查看:firewall-cmd --zone= public --query-port=80/tcp
删除:firewall-cmd --zone= public --remove-port=80/tcp --permanent
.
.
.
查看所有容器(包含已退出的容器):
docker ps -a
查看当前正在运行的容器
docker ps
删除docker中的容器可以使用如下命令:
docker rm 容器id
查看docker中所有镜像
docker images
删除docker中的镜像,我们可以使用如下命令:
docker rmi 镜像id
============================================================================================================================================================================================================
以下是我测试执行的全部命令与结果
[root@VM-16-13-centos ~]# yum list installed | grep docker
[root@VM-16-13-centos ~]# yum -y remove docker-ce-cli.x86_64
Loaded plugins: fastestmirror, langpacks
No Match for argument: docker-ce-cli.x86_64
No Packages marked for removal
[root@VM-16-13-centos ~]# yum -y remove docker-ce.x86_64
Loaded plugins: fastestmirror, langpacks
No Match for argument: docker-ce.x86_64
No Packages marked for removal
[root@VM-16-13-centos ~]# yum -y remove containerd.io
Loaded plugins: fastestmirror, langpacks
No Match for argument: containerd.io
No Packages marked for removal
[root@VM-16-13-centos ~]# yum install -y docker-ce docker-ce-cli containerd.io
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
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
No package docker-ce available.
No package docker-ce-cli available.
No package containerd.io available.
Error: Nothing to do
[root@VM-16-13-centos ~]# docker version
-bash: docker: command not found
[root@VM-16-13-centos ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package device-mapper-persistent-data.x86_64 0:0.8.5-2.el7 will be updated
---> Package device-mapper-persistent-data.x86_64 0:0.8.5-3.el7_9.2 will be an update
---> Package lvm2.x86_64 7:2.02.186-7.el7_8.2 will be updated
---> Package lvm2.x86_64 7:2.02.187-6.el7_9.5 will be an update
--> Processing Dependency: lvm2-libs = 7:2.02.187-6.el7_9.5 for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64
--> Running transaction check
---> Package lvm2-libs.x86_64 7:2.02.186-7.el7_8.2 will be updated
---> Package lvm2-libs.x86_64 7:2.02.187-6.el7_9.5 will be an update
--> Processing Dependency: device-mapper-event = 7:1.02.170-6.el7_9.5 for package: 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64
--> Running transaction check
---> Package device-mapper-event.x86_64 7:1.02.164-7.el7_8.2 will be updated
---> Package device-mapper-event.x86_64 7:1.02.170-6.el7_9.5 will be an update
--> Processing Dependency: device-mapper-event-libs = 7:1.02.170-6.el7_9.5 for package: 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64
--> Processing Dependency: device-mapper = 7:1.02.170-6.el7_9.5 for package: 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64
--> Running transaction check
---> Package device-mapper.x86_64 7:1.02.164-7.el7_8.2 will be updated
--> Processing Dependency: device-mapper = 7:1.02.164-7.el7_8.2 for package: 7:device-mapper-libs-1.02.164-7.el7_8.2.x86_64
---> Package device-mapper.x86_64 7:1.02.170-6.el7_9.5 will be an update
---> Package device-mapper-event-libs.x86_64 7:1.02.164-7.el7_8.2 will be updated
---> Package device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5 will be an update
--> Running transaction check
---> Package device-mapper-libs.x86_64 7:1.02.164-7.el7_8.2 will be updated
---> Package device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Updating:
device-mapper-persistent-data x86_64 0.8.5-3.el7_9.2 updates 423 k
lvm2 x86_64 7:2.02.187-6.el7_9.5 updates 1.3 M
Updating for dependencies:
device-mapper x86_64 7:1.02.170-6.el7_9.5 updates 297 k
device-mapper-event x86_64 7:1.02.170-6.el7_9.5 updates 192 k
device-mapper-event-libs x86_64 7:1.02.170-6.el7_9.5 updates 192 k
device-mapper-libs x86_64 7:1.02.170-6.el7_9.5 updates 325 k
lvm2-libs x86_64 7:2.02.187-6.el7_9.5 updates 1.1 M
Transaction Summary
====================================================================================================================================
Upgrade 2 Packages (+5 Dependent packages)
Total download size: 3.8 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/7): device-mapper-event-1.02.170-6.el7_9.5.x86_64.rpm | 192 kB 00:00:00
(2/7): device-mapper-1.02.170-6.el7_9.5.x86_64.rpm | 297 kB 00:00:00
(3/7): device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64.rpm | 192 kB 00:00:00
(4/7): device-mapper-libs-1.02.170-6.el7_9.5.x86_64.rpm | 325 kB 00:00:00
(5/7): device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64.rpm | 423 kB 00:00:00
(6/7): lvm2-2.02.187-6.el7_9.5.x86_64.rpm | 1.3 MB 00:00:00
(7/7): lvm2-libs-2.02.187-6.el7_9.5.x86_64.rpm | 1.1 MB 00:00:00
------------------------------------------------------------------------------------------------------------------------------------
Total 8.4 MB/s | 3.8 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Updating : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64 1/14
Updating : 7:device-mapper-1.02.170-6.el7_9.5.x86_64 2/14
Updating : 7:device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64 3/14
Updating : 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64 4/14
Updating : 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64 5/14
Updating : device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 6/14
Updating : 7:lvm2-2.02.187-6.el7_9.5.x86_64 7/14
Cleanup : 7:lvm2-2.02.186-7.el7_8.2.x86_64 8/14
Cleanup : 7:lvm2-libs-2.02.186-7.el7_8.2.x86_64 9/14
Cleanup : 7:device-mapper-event-1.02.164-7.el7_8.2.x86_64 10/14
Cleanup : 7:device-mapper-event-libs-1.02.164-7.el7_8.2.x86_64 11/14
Cleanup : 7:device-mapper-1.02.164-7.el7_8.2.x86_64 12/14
Cleanup : 7:device-mapper-libs-1.02.164-7.el7_8.2.x86_64 13/14
Cleanup : device-mapper-persistent-data-0.8.5-2.el7.x86_64 14/14
Verifying : 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64 1/14
Verifying : 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64 2/14
Verifying : device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 3/14
Verifying : 7:device-mapper-1.02.170-6.el7_9.5.x86_64 4/14
Verifying : 7:lvm2-2.02.187-6.el7_9.5.x86_64 5/14
Verifying : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64 6/14
Verifying : 7:device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64 7/14
Verifying : 7:device-mapper-1.02.164-7.el7_8.2.x86_64 8/14
Verifying : device-mapper-persistent-data-0.8.5-2.el7.x86_64 9/14
Verifying : 7:lvm2-libs-2.02.186-7.el7_8.2.x86_64 10/14
Verifying : 7:device-mapper-event-1.02.164-7.el7_8.2.x86_64 11/14
Verifying : 7:lvm2-2.02.186-7.el7_8.2.x86_64 12/14
Verifying : 7:device-mapper-libs-1.02.164-7.el7_8.2.x86_64 13/14
Verifying : 7:device-mapper-event-libs-1.02.164-7.el7_8.2.x86_64 14/14
Updated:
device-mapper-persistent-data.x86_64 0:0.8.5-3.el7_9.2 lvm2.x86_64 7:2.02.187-6.el7_9.5
Dependency Updated:
device-mapper.x86_64 7:1.02.170-6.el7_9.5 device-mapper-event.x86_64 7:1.02.170-6.el7_9.5
device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5 device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5
lvm2-libs.x86_64 7:2.02.187-6.el7_9.5
Complete!
[root@VM-16-13-centos ~]# yum-config-manager --add-repo https://mirrors.cloud.tencent.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: https://mirrors.cloud.tencent.com/docker-ce/linux/centos/docker-ce.repo
grabbing file https://mirrors.cloud.tencent.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@VM-16-13-centos ~]# yum install -y docker-ce docker-ce-cli containerd.io
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
docker-ce-stable | 3.5 kB 00:00:00
(1/2): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:00
(2/2): docker-ce-stable/7/x86_64/primary_db | 75 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.5.11-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.5.11-3.1.el7.x86_64
---> Package docker-ce.x86_64 3:20.10.14-3.el7 will be installed
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.14-3.el7.x86_64
--> Processing Dependency: libcgroup for package: 3:docker-ce-20.10.14-3.el7.x86_64
---> Package docker-ce-cli.x86_64 1:20.10.14-3.el7 will be installed
--> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.14-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
--> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
---> Package docker-ce-rootless-extras.x86_64 0:20.10.14-3.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.14-3.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-20.10.14-3.el7.x86_64
---> Package docker-scan-plugin.x86_64 0:0.17.0-3.el7 will be installed
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
--> Running transaction check
---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
--> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be installed
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Installing:
containerd.io x86_64 1.5.11-3.1.el7 docker-ce-stable 29 M
docker-ce x86_64 3:20.10.14-3.el7 docker-ce-stable 22 M
docker-ce-cli x86_64 1:20.10.14-3.el7 docker-ce-stable 30 M
Installing for dependencies:
audit-libs-python x86_64 2.8.5-4.el7 os 76 k
checkpolicy x86_64 2.5-8.el7 os 295 k
container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k
docker-ce-rootless-extras x86_64 20.10.14-3.el7 docker-ce-stable 8.1 M
docker-scan-plugin x86_64 0.17.0-3.el7 docker-ce-stable 3.7 M
fuse-overlayfs x86_64 0.7.2-6.el7_8 extras 54 k
fuse3-libs x86_64 3.6.1-4.el7 extras 82 k
libcgroup x86_64 0.41-21.el7 os 66 k
libsemanage-python x86_64 2.5-14.el7 os 113 k
policycoreutils-python x86_64 2.5-34.el7 os 457 k
python-IPy noarch 0.75-6.el7 os 32 k
setools-libs x86_64 3.3.8-4.el7 os 620 k
slirp4netns x86_64 0.4.3-4.el7_8 extras 81 k
Transaction Summary
====================================================================================================================================
Install 3 Packages (+13 Dependent packages)
Total download size: 95 M
Installed size: 383 M
Downloading packages:
(1/16): audit-libs-python-2.8.5-4.el7.x86_64.rpm | 76 kB 00:00:00
(2/16): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm | 40 kB 00:00:00
(3/16): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-20.10.14-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-ce-20.10.14-3.el7.x86_64.rpm is not installed
(4/16): docker-ce-20.10.14-3.el7.x86_64.rpm | 22 MB 00:00:02
(5/16): containerd.io-1.5.11-3.1.el7.x86_64.rpm | 29 MB 00:00:03
(6/16): docker-ce-rootless-extras-20.10.14-3.el7.x86_64.rpm | 8.1 MB 00:00:01
(7/16): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00:00
(8/16): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00
(9/16): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00:00
(10/16): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00:00
(11/16): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00
(12/16): policycoreutils-python-2.5-34.el7.x86_64.rpm | 457 kB 00:00:00
(13/16): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00:00
(14/16): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00
(15/16): docker-scan-plugin-0.17.0-3.el7.x86_64.rpm | 3.7 MB 00:00:01
(16/16): docker-ce-cli-20.10.14-3.el7.x86_64.rpm | 30 MB 00:00:05
------------------------------------------------------------------------------------------------------------------------------------
Total 12 MB/s | 95 MB 00:00:07
Retrieving key from https://mirrors.tencent.com/docker-ce/linux/centos/gpg
Importing GPG key 0x621E9F35:
Userid : "Docker Release (CE rpm) <docker@docker.com>"
Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
From : https://mirrors.tencent.com/docker-ce/linux/centos/gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : docker-scan-plugin-0.17.0-3.el7.x86_64 1/16
Installing : 1:docker-ce-cli-20.10.14-3.el7.x86_64 2/16
Installing : libcgroup-0.41-21.el7.x86_64 3/16
Installing : setools-libs-3.3.8-4.el7.x86_64 4/16
Installing : audit-libs-python-2.8.5-4.el7.x86_64 5/16
Installing : python-IPy-0.75-6.el7.noarch 6/16
Installing : slirp4netns-0.4.3-4.el7_8.x86_64 7/16
Installing : libsemanage-python-2.5-14.el7.x86_64 8/16
Installing : fuse3-libs-3.6.1-4.el7.x86_64 9/16
Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64 10/16
Installing : checkpolicy-2.5-8.el7.x86_64 11/16
Installing : policycoreutils-python-2.5-34.el7.x86_64 12/16
Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 13/16
setsebool: SELinux is disabled.
Installing : containerd.io-1.5.11-3.1.el7.x86_64 14/16
Installing : docker-ce-rootless-extras-20.10.14-3.el7.x86_64 15/16
Installing : 3:docker-ce-20.10.14-3.el7.x86_64 16/16
Verifying : 3:docker-ce-20.10.14-3.el7.x86_64 1/16
Verifying : containerd.io-1.5.11-3.1.el7.x86_64 2/16
Verifying : checkpolicy-2.5-8.el7.x86_64 3/16
Verifying : fuse3-libs-3.6.1-4.el7.x86_64 4/16
Verifying : fuse-overlayfs-0.7.2-6.el7_8.x86_64 5/16
Verifying : libsemanage-python-2.5-14.el7.x86_64 6/16
Verifying : docker-ce-rootless-extras-20.10.14-3.el7.x86_64 7/16
Verifying : slirp4netns-0.4.3-4.el7_8.x86_64 8/16
Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 9/16
Verifying : python-IPy-0.75-6.el7.noarch 10/16
Verifying : 1:docker-ce-cli-20.10.14-3.el7.x86_64 11/16
Verifying : policycoreutils-python-2.5-34.el7.x86_64 12/16
Verifying : docker-scan-plugin-0.17.0-3.el7.x86_64 13/16
Verifying : audit-libs-python-2.8.5-4.el7.x86_64 14/16
Verifying : setools-libs-3.3.8-4.el7.x86_64 15/16
Verifying : libcgroup-0.41-21.el7.x86_64 16/16
Installed:
containerd.io.x86_64 0:1.5.11-3.1.el7 docker-ce.x86_64 3:20.10.14-3.el7 docker-ce-cli.x86_64 1:20.10.14-3.el7
Dependency Installed:
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 docker-ce-rootless-extras.x86_64 0:20.10.14-3.el7
docker-scan-plugin.x86_64 0:0.17.0-3.el7 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 policycoreutils-python.x86_64 0:2.5-34.el7
python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7
slirp4netns.x86_64 0:0.4.3-4.el7_8
Complete!
[root@VM-16-13-centos ~]#
Last login: Wed Mar 30 09:17:28 2022 from 106.55.166.162
[root@VM-16-13-centos ~]# docker version
Client: Docker Engine - Community
Version: 20.10.14
API version: 1.41
Go version: go1.16.15
Git commit: a224086
Built: Thu Mar 24 01:49:57 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@VM-16-13-centos ~]#
[root@VM-16-13-centos ~]#
[root@VM-16-13-centos ~]#
[root@VM-16-13-centos ~]# systemctl start docker
[root@VM-16-13-centos ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@VM-16-13-centos ~]# service docker status
Redirecting to /bin/systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2022-03-30 09:30:24 CST; 18s ago
Docs: https://docs.docker.com
Main PID: 3408 (dockerd)
CGroup: /system.slice/docker.service
└─3408 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Mar 30 09:30:24 VM-16-13-centos dockerd[3408]: time="2022-03-30T09:30:24.551917804+08:00" level=info msg="scheme \"unix\" n...e=grpc
Mar 30 09:30:24 VM-16-13-centos dockerd[3408]: time="2022-03-30T09:30:24.551928494+08:00" level=info msg="ccResolverWrapper...e=grpc
Mar 30 09:30:24 VM-16-13-centos dockerd[3408]: time="2022-03-30T09:30:24.551934806+08:00" level=info msg="ClientConn switch...e=grpc
Mar 30 09:30:24 VM-16-13-centos dockerd[3408]: time="2022-03-30T09:30:24.612512048+08:00" level=info msg="Loading container...tart."
Mar 30 09:30:24 VM-16-13-centos dockerd[3408]: time="2022-03-30T09:30:24.746473633+08:00" level=info msg="Default bridge (d...dress"
Mar 30 09:30:24 VM-16-13-centos dockerd[3408]: time="2022-03-30T09:30:24.794590615+08:00" level=info msg="Loading containers: done."
Mar 30 09:30:24 VM-16-13-centos dockerd[3408]: time="2022-03-30T09:30:24.815536465+08:00" level=info msg="Docker daemon" co....10.14
Mar 30 09:30:24 VM-16-13-centos dockerd[3408]: time="2022-03-30T09:30:24.815612898+08:00" level=info msg="Daemon has comple...ation"
Mar 30 09:30:24 VM-16-13-centos dockerd[3408]: time="2022-03-30T09:30:24.847488108+08:00" level=info msg="API listen on /va....sock"
Mar 30 09:30:24 VM-16-13-centos systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
[root@VM-16-13-centos ~]# mkdir -p /etc/docker
[root@VM-16-13-centos ~]# tee /etc/docker/daemon.json <<-'EOF'
> {
> "registry-mirrors": ["https://mirror.ccs.tencentyun.com"]
> }
> EOF
{
"registry-mirrors": ["https://mirror.ccs.tencentyun.com"]
}
[root@VM-16-13-centos ~]# systemctl daemon-reload && systemctl restart docker
[root@VM-16-13-centos ~]# docker run --name=hello hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:bfea6278a0a267fad2634554f4f0c6f31981eea41c553fdf5a83e95a41d40c38
Status: Downloaded newer image for 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/
[root@VM-16-13-centos ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7607e9cc06cc hello-world "/hello" 4 minutes ago Exited (0) 4 minutes ago hello
[root@VM-16-13-centos ~]# docker pull johngong/calibre-web
Using default tag: latest
latest: Pulling from johngong/calibre-web
59bf1c3509f3: Pull complete
31c18df28697: Pull complete
2b880bb8acc2: Pull complete
Digest: sha256:d38b7a39c93ff08fd5ff89623511d619a3518ec081954f2511ea01116382d78f
Status: Downloaded newer image for johngong/calibre-web:latest
docker.io/johngong/calibre-web:latest
[root@VM-16-13-centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
johngong/calibre-web latest 2ac832a171eb 2 weeks ago 863MB
hello-world latest feb5d9fea6a5 6 months ago 13.3kB
[root@VM-16-13-centos ~]# docker create --name=calibre-web -p 80:8083 -v /data/calibre-web/library:/library -e WEBLANGUAGE=zh_CN johngong/calibre-web
d5bd8367618f376a9ef40ef4f8c4f89abe883c053da17c3574525e7c0dbf7ee6
[root@VM-16-13-centos ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d5bd8367618f johngong/calibre-web "/init" 32 seconds ago Created calibre-web
7607e9cc06cc hello-world "/hello" 8 minutes ago Exited (0) 8 minutes ago hello
[root@VM-16-13-centos ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-16-13-centos ~]# docker start calibre-web
calibre-web
[root@VM-16-13-centos ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d5bd8367618f johngong/calibre-web "/init" 6 minutes ago Up 5 seconds 8080/tcp, 0.0.0.0:80->8083/tcp, :::80->8083/tcp calibre-web
[root@VM-16-13-centos ~]# docker stop calibre-web
calibre-web
[root@VM-16-13-centos ~]# docker kill calibre-web
Error response from daemon: Cannot kill container: calibre-web: Container d5bd8367618f376a9ef40ef4f8c4f89abe883c053da17c3574525e7c0dbf7ee6 is not running
[root@VM-16-13-centos ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@VM-16-13-centos ~]# docker rm hello
hello
[root@VM-16-13-centos ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d5bd8367618f johngong/calibre-web "/init" 13 minutes ago Exited (0) 4 minutes ago calibre-web
[root@VM-16-13-centos ~]# docker start calibre-web
calibre-web
[root@VM-16-13-centos ~]# docker rm calibre-web
Error response from daemon: You cannot remove a running container d5bd8367618f376a9ef40ef4f8c4f89abe883c053da17c3574525e7c0dbf7ee6. Stop the container before attempting removal or force remove
[root@VM-16-13-centos ~]# docker rm -f calibre-web
calibre-web
[root@VM-16-13-centos ~]# docker rmi hello-world
Untagged: hello-world:latest
Untagged: hello-world@sha256:bfea6278a0a267fad2634554f4f0c6f31981eea41c553fdf5a83e95a41d40c38
Deleted: sha256:feb5d9fea6a5e9606aa995e879d862b825965ba48de054caab5ef356dc6b3412
Deleted: sha256:e07ee1baac5fae6a26f30cabfe54a36d3402f96afda318fe0a96cec4ca393359
[root@VM-16-13-centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
johngong/calibre-web latest 2ac832a171eb 2 weeks ago 863MB
[root@VM-16-13-centos ~]# docker images -q
2ac832a171eb
[root@VM-16-13-centos ~]# docker rmi `docker images -q`
Untagged: johngong/calibre-web:latest
Untagged: johngong/calibre-web@sha256:d38b7a39c93ff08fd5ff89623511d619a3518ec081954f2511ea01116382d78f
Deleted: sha256:2ac832a171eb30432d9f42c4829bc4ee092ec360328dbd618815ac3483bc09fc
Deleted: sha256:f1b3344a76bf6f4a971385a57678c75722b3276f702f3bb5cf30ec8faeda75a9
Deleted: sha256:8389628de96a92f5068a36d9a247f8876b21f18878fe76410e03ef4550c5016c
Deleted: sha256:8d3ac3489996423f53d6087c81180006263b79f206d3fdec9e66f0e27ceb8759
[root@VM-16-13-centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@VM-16-13-centos ~]# ^C
[root@VM-16-13-centos ~]#
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。