Docker镜像管理快速入门

简介: docker

CentOS Linux release 7.9.2009 (Core)

1,yum工具安装
yum install yum-utils -y

2,配置docker镜像仓库
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

3,docker软件安装
缺少container-selinux 依赖软件包。

[root@i-AAB0CE27 yum.repos.d]# yum install docker-ce-18.03.1.ce -y
Loaded plugins: fastestmirror
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 | 70 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:18.03.1.ce-1.el7.centos will be installed
--> Processing Dependency: libseccomp >= 2.3 for package: docker-ce-18.03.1.ce-1.el7.centos.x86_64
--> Processing Dependency: container-selinux >= 2.9 for package: docker-ce-18.03.1.ce-1.el7.centos.x86_64
--> Processing Dependency: pigz for package: docker-ce-18.03.1.ce-1.el7.centos.x86_64
--> Processing Dependency: libcgroup for package: docker-ce-18.03.1.ce-1.el7.centos.x86_64
--> Processing Dependency: libltdl.so.7()(64bit) for package: docker-ce-18.03.1.ce-1.el7.centos.x86_64
--> Processing Dependency: libseccomp.so.2()(64bit) for package: docker-ce-18.03.1.ce-1.el7.centos.x86_64
--> Running transaction check
---> Package docker-ce.x86_64 0:18.03.1.ce-1.el7.centos will be installed
--> Processing Dependency: container-selinux >= 2.9 for package: docker-ce-18.03.1.ce-1.el7.centos.x86_64
--> Processing Dependency: pigz for package: docker-ce-18.03.1.ce-1.el7.centos.x86_64
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
---> Package libseccomp.x86_64 0:2.3.1-4.el7 will be installed
---> Package libtool-ltdl.x86_64 0:2.4.2-22.el7_3 will be installed
--> Finished Dependency Resolution
Error: Package: docker-ce-18.03.1.ce-1.el7.centos.x86_64 (docker-ce-stable)

       Requires: pigz

Error: Package: docker-ce-18.03.1.ce-1.el7.centos.x86_64 (docker-ce-stable)

       Requires: container-selinux >= 2.9

You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
[root@i-AAB0CE27 yum.repos.d]# yum install container-selinux
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
No package container-selinux available.
Error: Nothing to

4,配置依赖仓库

要不然确实container-selinux软件依赖包

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

5,docker软件安装
[root@i-AAB0CE27 yum.repos.d]# yum install docker-ce-18.03.1.ce -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

  • base: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com

base/7/x86_64/primary_db | 6.1 MB 00:00:05
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:18.03.1.ce-1.el7.centos will be installed
--> Processing Dependency: libseccomp >= 2.3 for package: docker-ce-18.03.1.ce-1.el7.centos.x86_64
--> Processing Dependency: container-selinux >= 2.9 for package: docker-ce-18.03.1.ce-1.el7.centos.x86_64
--> Processing Dependency: pigz for package: docker-ce-18.03.1.ce-1.el7.centos.x86_64
--> Processing Dependency: libcgroup for package: docker-ce-18.03.1.ce-1.el7.centos.x86_64
--> Processing Dependency: libltdl.so.7()(64bit) for package: docker-ce-18.03.1.ce-1.el7.centos.x86_64
--> Processing Dependency: libseccomp.so.2()(64bit) for package: docker-ce-18.03.1.ce-1.el7.centos.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 libcgroup.x86_64 0:0.41-21.el7 will be installed
---> Package libseccomp.x86_64 0:2.3.1-4.el7 will be installed
---> Package libtool-ltdl.x86_64 0:2.4.2-22.el7_3 will be installed
---> Package pigz.x86_64 0:2.3.3-1.el7.centos will be installed
--> Running transaction check
---> 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
--> 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 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:
docker-ce x86_64 18.03.1.ce-1.el7.centos docker-ce-stable 35 M
Installing for dependencies:
audit-libs-python x86_64 2.8.5-4.el7 base 76 k
checkpolicy x86_64 2.5-8.el7 base 295 k
container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k
libcgroup x86_64 0.41-21.el7 base 66 k
libseccomp x86_64 2.3.1-4.el7 base 56 k
libsemanage-python x86_64 2.5-14.el7 base 113 k
libtool-ltdl x86_64 2.4.2-22.el7_3 base 49 k
pigz x86_64 2.3.3-1.el7.centos extras 68 k
policycoreutils-python x86_64 2.5-34.el7 base 457 k
python-IPy noarch 0.75-6.el7 base 32 k
setools-libs x86_64 3.3.8-4.el7 base 620 k

Transaction Summary

Install 1 Package (+11 Dependent packages)

Total download size: 36 M
Installed size: 40 M
Downloading packages:
libcgroup-0.41-21.el7.x86_64.r FAILED
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/Packages/libcgroup-0.41-21.el7.x86_64.rpm: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"
Trying other mirror.
warning: /var/cache/yum/x86_64/7/extras/packages/container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm is not installed
(1/12): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm | 40 kB 00:00:00
Public key for audit-libs-python-2.8.5-4.el7.x86_64.rpm is not installed
(2/12): audit-libs-python-2.8.5-4.el7.x86_64.rpm | 76 kB 00:00:00
(3/12): libseccomp-2.3.1-4.el7.x86_64.rpm | 56 kB 00:00:00
(4/12): libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm | 49 kB 00:00:00
(5/12): pigz-2.3.3-1.el7.centos.x86_64.rpm | 68 kB 00:00:00
(6/12): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00
(7/12): policycoreutils-python-2.5-34.el7.x86_64.rpm | 457 kB 00:00:00
(8/12): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00:00
(9/12): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00
checkpolicy-2.5-8.el7.x86_64.r FAILED ======================= ] 1.0 MB/s | 30 MB 00:00:05 ETA
http://mirrors.aliyuncs.com/centos/7/os/x86_64/Packages/libsemanage-python-2.5-14.el7.x86_64.rpm: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/Packages/libsemanage-python-2.5-14.el7.x86_64.rpm: (28, 'Connection timed out after 30001 milliseconds')
Trying other mirror.
(10/12): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:00:00
(11/12): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm is not installed

(12/12): docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm | 35 MB 00:00:35

Total 1.0 MB/s | 36 MB 00:00:35
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Retrieving key from https://mirrors.aliyun.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.aliyun.com/docker-ce/linux/centos/gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libcgroup-0.41-21.el7.x86_64 1/12
Installing : pigz-2.3.3-1.el7.centos.x86_64 2/12
Installing : setools-libs-3.3.8-4.el7.x86_64 3/12
Installing : audit-libs-python-2.8.5-4.el7.x86_64 4/12
Installing : libtool-ltdl-2.4.2-22.el7_3.x86_64 5/12
Installing : python-IPy-0.75-6.el7.noarch 6/12
Installing : libseccomp-2.3.1-4.el7.x86_64 7/12
Installing : libsemanage-python-2.5-14.el7.x86_64 8/12
Installing : checkpolicy-2.5-8.el7.x86_64 9/12
Installing : policycoreutils-python-2.5-34.el7.x86_64 10/12
Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 11/12
Installing : docker-ce-18.03.1.ce-1.el7.centos.x86_64 12/12
Verifying : checkpolicy-2.5-8.el7.x86_64 1/12
Verifying : docker-ce-18.03.1.ce-1.el7.centos.x86_64 2/12
Verifying : libsemanage-python-2.5-14.el7.x86_64 3/12
Verifying : libseccomp-2.3.1-4.el7.x86_64 4/12
Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 5/12
Verifying : python-IPy-0.75-6.el7.noarch 6/12
Verifying : libtool-ltdl-2.4.2-22.el7_3.x86_64 7/12
Verifying : policycoreutils-python-2.5-34.el7.x86_64 8/12
Verifying : audit-libs-python-2.8.5-4.el7.x86_64 9/12
Verifying : setools-libs-3.3.8-4.el7.x86_64 10/12
Verifying : pigz-2.3.3-1.el7.centos.x86_64 11/12
Verifying : libcgroup-0.41-21.el7.x86_64 12/12

Installed:
docker-ce.x86_64 0:18.03.1.ce-1.el7.centos

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
libcgroup.x86_64 0:0.41-21.el7 libseccomp.x86_64 0:2.3.1-4.el7 libsemanage-python.x86_64 0:2.5-14.el7
libtool-ltdl.x86_64 0:2.4.2-22.el7_3 pigz.x86_64 0:2.3.3-1.el7.centos 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

Complete!
6,启动docker并检查版本信息
[root@i-AAB0CE27 yum.repos.d]# systemctl start docker
[root@i-AAB0CE27 yum.repos.d]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@i-AAB0CE27 yum.repos.d]# docker --version
Docker version 18.03.1-ce, build 9ee9f40

相关文章
|
10天前
|
缓存 Linux 网络安全
docker的镜像无法下载如何解决?
【10月更文挑战第31天】docker的镜像无法下载如何解决?
283 28
|
23天前
|
缓存 监控 持续交付
|
6天前
|
存储 关系型数据库 Linux
【赵渝强老师】什么是Docker的镜像
Docker镜像是一个只读模板,包含应用程序及其运行所需的依赖环境。镜像采用分层文件系统,每次修改都会以读写层形式添加到原只读模板上。内核bootfs用于加载Linux内核,根镜像相当于操作系统,上方为应用层。镜像在物理存储上是一系列文件的集合,默认存储路径为“/var/lib/docker”。
|
11天前
|
存储 监控 Linux
docker构建镜像详解!!!
本文回顾了Docker的基本命令和管理技巧,包括容器和镜像的增删改查操作,容器的生命周期管理,以及如何通过端口映射和数据卷实现容器与宿主机之间的网络通信和数据持久化。文章还详细介绍了如何使用Docker部署一个简单的Web应用,并通过数据卷映射实现配置文件和日志的管理。最后,文章总结了如何制作自定义镜像,包括Nginx、Python3和CentOS镜像,以及如何制作私有云盘镜像。
74 2
|
13天前
|
关系型数据库 MySQL Docker
docker环境下mysql镜像启动后权限更改问题的解决
在Docker环境下运行MySQL容器时,权限问题是一个常见的困扰。通过正确设置目录和文件的权限,可以确保MySQL容器顺利启动并正常运行。本文提供了多种解决方案,包括在主机上设置正确的权限、使用Dockerfile和Docker Compose进行配置、在容器启动后手动更改权限以及使用 `init`脚本自动更改权限。根据实际情况选择合适的方法,可以有效解决MySQL容器启动后的权限问题。希望本文对您在Docker环境下运行MySQL容器有所帮助。
21 1
|
14天前
|
存储 Java 开发者
成功优化!Java 基础 Docker 镜像从 674MB 缩减到 58MB 的经验分享
本文分享了如何通过 jlink 和 jdeps 工具将 Java 基础 Docker 镜像从 674MB 优化至 58MB 的经验。首先介绍了选择合适的基础镜像的重要性,然后详细讲解了使用 jlink 构建自定义 JRE 镜像的方法,并通过 jdeps 自动化模块依赖分析,最终实现了镜像的大幅缩减。此外,文章还提供了实用的 .dockerignore 文件技巧和选择安全、兼容的基础镜像的建议,帮助开发者提升镜像优化的效果。
|
19天前
|
存储 缓存 Java
Java应用瘦身记:Docker镜像从674MB优化至58MB的实践指南
【10月更文挑战第22天】 在容器化时代,Docker镜像的大小直接影响到应用的部署速度和运行效率。一个轻量级的Docker镜像可以减少存储成本、加快启动时间,并提高资源利用率。本文将分享如何将一个Java基础Docker镜像从674MB缩减到58MB的实践经验。
29 1
|
26天前
|
Docker 容器
docker:记录如何在x86架构上构造和使用arm架构的镜像
为了实现国产化适配,需将原x86平台上的Docker镜像转换为适用于ARM平台的镜像。本文介绍了如何配置Docker buildx环境,包括检查Docker版本、安装buildx插件、启用实验性功能及构建多平台镜像的具体步骤。通过这些操作,可以在x86平台上成功构建并运行ARM64镜像,实现跨平台的应用部署。
436 2
|
30天前
|
网络协议 Docker 容器
docker pull命令拉取镜像失败的解决方案
docker pull命令拉取镜像失败的解决方案
718 1
|
6天前
|
缓存 JavaScript 安全
深入理解Docker镜像构建过程
深入理解Docker镜像构建过程
19 0