docker镜像制作和管理(代码片段)

Janzen_Q Janzen_Q     2023-04-27     351

关键词:

一、Docker镜像说明

二、基于容器通过 docker commit 手动制作镜像

1、基于容器手动制作镜像步骤

1、下载官方系统镜像

2、基于官方基础镜像启动容器,并进入容器

3、在容器中进行配置操作

  3.1、安装基础工具

  3.2、配置运行环境

  3.3、安装并配置服务

  3.4、存放业务程序代码

4、docker commit 提交生成新镜像

5、基于定制镜像生成容器并测试

2、基于centos7官方镜像,手动制作yum安装nginx定制镜像

2.1、下载centos7官方镜像,并启动进入容器

centos官方镜像:https://hub.docker.com/_/centos/tags

[root@Docker-Ubu1804-p11:~]# docker pull centos:7
7: Pulling from library/centos
2d473b07cdd5: Pull complete 
Digest: sha256:9d4bcbbb213dfd745b58be38b13b996ebb5ac315fe75711bd618426a630e0987
Status: Downloaded newer image for centos:7
docker.io/library/centos:7
[root@Docker-Ubu1804-p11:~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
alpine              latest              c059bfaa849c        17 months ago       5.59MB
hello-world         latest              feb5d9fea6a5        19 months ago       13.3kB
centos              7                   eeb6ee3f44bd        19 months ago       204MB
[root@Docker-Ubu1804-p11:~]# docker run -d --name centos-nginx centos:7 tail -f /etc/hosts
502a7a7faae8b7a3c3fa177baec1009d1bc9caabb8b782f887767b35e16ecb8a
[root@Docker-Ubu1804-p11:~]# docker ps
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS               NAMES
502a7a7faae8        centos:7            "tail -f /etc/hosts"   8 seconds ago       Up 7 seconds                            centos-nginx
[root@Docker-Ubu1804-p11:~]# docker exec -it centos-nginx bash
[root@502a7a7faae8 /]# 

 

2.2、在容器内安装基础工具,并配置环境

 

##配置容器内 yum
[root@502a7a7faae8 /]# rm -rf /etc/yum.repos.d/*
[root@502a7a7faae8 /]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2523  100  2523    0     0  28084      0 --:--:-- --:--:-- --:--:-- 28348
[root@502a7a7faae8 /]# ls /etc/yum.repos.d/
CentOS-Base.repo
[root@502a7a7faae8 /]# yum clean all
Loaded plugins: fastestmirror, ovl
Cleaning repos: base extras updates
[root@502a7a7faae8 /]# yum makecache fast
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                     | 3.6 kB  00:00:00     
extras                                                                                                                   | 2.9 kB  00:00:00     
updates                                                                                                                  | 2.9 kB  00:00:00     
(1/4): base/7/x86_64/group_gz                                                                                            | 153 kB  00:00:00     
(2/4): extras/7/x86_64/primary_db                                                                                        | 249 kB  00:00:00     
(3/4): updates/7/x86_64/primary_db                                                                                       |  20 MB  00:00:08     
base/7/x86_64/primary_db       FAILED                                          
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
(4/4): base/7/x86_64/primary_db                                                                                          | 6.1 MB  00:00:01     
Metadata Cache Created


##yum安装常用基础工具
[root@502a7a7faae8 /]# yum install -y psmisc tree wget vim net-tools bash-completion
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package bash-completion.noarch 1:2.1-8.el7 will be installed
---> Package net-tools.x86_64 0:2.0-0.25.20131004git.el7 will be installed
---> Package psmisc.x86_64 0:22.20-17.el7 will be installed
---> Package tree.x86_64 0:1.6.0-10.el7 will be installed
---> Package vim-enhanced.x86_64 2:7.4.629-8.el7_9 will be installed
--> Processing Dependency: vim-common = 2:7.4.629-8.el7_9 for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
--> Processing Dependency: which for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
--> Processing Dependency: perl(:MODULE_COMPAT_5.16.3) for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
--> Processing Dependency: libperl.so()(64bit) for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
--> Processing Dependency: libgpm.so.2()(64bit) for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Running transaction check
---> Package gpm-libs.x86_64 0:1.20.7-6.el7 will be installed
---> Package perl.x86_64 4:5.16.3-299.el7_9 will be installed
--> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl-macros for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(constant) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Getopt::Long) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Exporter) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-299.el7_9.x86_64
--> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-299.el7_9.x86_64
---> Package perl-libs.x86_64 4:5.16.3-299.el7_9 will be installed
---> Package vim-common.x86_64 2:7.4.629-8.el7_9 will be installed
--> Processing Dependency: vim-filesystem for package: 2:vim-common-7.4.629-8.el7_9.x86_64
---> Package which.x86_64 0:2.20-7.el7 will be installed
--> Running transaction check
---> Package perl-Carp.noarch 0:1.26-244.el7 will be installed
---> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed
---> Package perl-File-Path.noarch 0:2.09-2.el7 will be installed
---> Package perl-File-Temp.noarch 0:0.23.01-3.el7 will be installed
---> Package perl-Filter.x86_64 0:1.49-3.el7 will be installed
---> Package perl-Getopt-Long.noarch 0:2.40-3.el7 will be installed
--> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-3.el7.noarch
--> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-3.el7.noarch
---> Package perl-PathTools.x86_64 0:3.40-5.el7 will be installed
---> Package perl-Pod-Simple.noarch 1:3.28-4.el7 will be installed
--> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
--> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
---> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 will be installed
---> Package perl-Socket.x86_64 0:2.010-5.el7 will be installed
---> Package perl-Storable.x86_64 0:2.45-3.el7 will be installed
---> Package perl-Time-HiRes.x86_64 4:1.9725-3.el7 will be installed
---> Package perl-Time-Local.noarch 0:1.2300-2.el7 will be installed
---> Package perl-constant.noarch 0:1.27-2.el7 will be installed
---> Package perl-macros.x86_64 4:5.16.3-299.el7_9 will be installed
---> Package perl-threads.x86_64 0:1.87-4.el7 will be installed
---> Package perl-threads-shared.x86_64 0:1.43-6.el7 will be installed
---> Package vim-filesystem.x86_64 2:7.4.629-8.el7_9 will be installed
--> Running transaction check
---> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed
---> Package perl-Pod-Escapes.noarch 1:1.04-299.el7_9 will be installed
---> Package perl-Pod-Usage.noarch 0:1.63-3.el7 will be installed
--> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.el7.noarch
--> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.el7.noarch
---> Package perl-Text-ParseWords.noarch 0:3.29-4.el7 will be installed
--> Running transaction check
---> Package perl-Pod-Perldoc.noarch 0:3.20-4.el7 will be installed
--> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
--> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
--> Processing Dependency: groff-base for package: perl-Pod-Perldoc-3.20-4.el7.noarch
---> Package perl-podlators.noarch 0:2.5.1-3.el7 will be installed
--> Running transaction check
---> Package groff-base.x86_64 0:1.22.2-8.el7 will be installed
---> Package perl-HTTP-Tiny.noarch 0:0.033-3.el7 will be installed
---> Package perl-parent.noarch 1:0.225-244.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
 Package                                  Arch                     Version                                      Repository                 Size
================================================================================================================================================
Installing:
 bash-completion                          noarch                   1:2.1-8.el7                                  base                       87 k
 net-tools                                x86_64                   2.0-0.25.20131004git.el7                     base                      306 k
 psmisc                                   x86_64                   22.20-17.el7                                 base                      141 k
 tree                                     x86_64                   1.6.0-10.el7                                 base                       46 k
 vim-enhanced                             x86_64                   2:7.4.629-8.el7_9                            updates                   1.1 M
 wget                                     x86_64                   1.14-18.el7_6.1                              base                      547 k
Installing for dependencies:
 gpm-libs                                 x86_64                   1.20.7-6.el7                                 base                       32 k
 groff-base                               x86_64                   1.22.2-8.el7                                 base                      942 k
 perl                                     x86_64                   4:5.16.3-299.el7_9                           updates                   8.0 M
 perl-Carp                                noarch                   1.26-244.el7                                 base                       19 k
 perl-Encode                              x86_64                   2.51-7.el7                                   base                      1.5 M
 perl-Exporter                            noarch                   5.68-3.el7                                   base                       28 k
 perl-File-Path                           noarch                   2.09-2.el7                                   base                       26 k
 perl-File-Temp                           noarch                   0.23.01-3.el7                                base                       56 k
 perl-Filter                              x86_64                   1.49-3.el7                                   base                       76 k
 perl-Getopt-Long                         noarch                   2.40-3.el7                                   base                       56 k
 perl-HTTP-Tiny                           noarch                   0.033-3.el7                                  base                       38 k
 perl-PathTools                           x86_64                   3.40-5.el7                                   base                       82 k
 perl-Pod-Escapes                         noarch                   1:1.04-299.el7_9                             updates                    52 k
 perl-Pod-Perldoc                         noarch                   3.20-4.el7                                   base                       87 k
 perl-Pod-Simple                          noarch                   1:3.28-4.el7                                 base                      216 k
 perl-Pod-Usage                           noarch                   1.63-3.el7                                   base                       27 k
 perl-Scalar-List-Utils                   x86_64                   1.27-248.el7                                 base                       36 k
 perl-Socket                              x86_64                   2.010-5.el7                                  base                       49 k
 perl-Storable                            x86_64                   2.45-3.el7                                   base                       77 k
 perl-Text-ParseWords                     noarch                   3.29-4.el7                                   base                       14 k
 perl-Time-HiRes                          x86_64                   4:1.9725-3.el7                               base                       45 k
 perl-Time-Local                          noarch                   1.2300-2.el7                                 base                       24 k
 perl-constant                            noarch                   1.27-2.el7                                   base                       19 k
 perl-libs                                x86_64                   4:5.16.3-299.el7_9                           updates                   690 k
 perl-macros                              x86_64                   4:5.16.3-299.el7_9                           updates                    44 k
 perl-parent                              noarch                   1:0.225-244.el7                              base                       12 k
 perl-podlators                           noarch                   2.5.1-3.el7                                  base                      112 k
 perl-threads                             x86_64                   1.87-4.el7                                   base                       49 k
 perl-threads-shared                      x86_64                   1.43-6.el7                                   base                       39 k
 vim-common                               x86_64                   2:7.4.629-8.el7_9                            updates                   5.9 M
 vim-filesystem                           x86_64                   2:7.4.629-8.el7_9                            updates                    11 k
 which                                    x86_64                   2.20-7.el7                                   base                       41 k

Transaction Summary
================================================================================================================================================
Install  6 Packages (+32 Dependent packages)

Total download size: 20 M
Installed size: 67 M
Downloading packages:
groff-base-1.22.2-8.el7.x86_64 FAILED                                          
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/Packages/groff-base-1.22.2-8.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/base/packages/gpm-libs-1.20.7-6.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY-:-- ETA 
Public key for gpm-libs-1.20.7-6.el7.x86_64.rpm is not installed
(1/38): gpm-libs-1.20.7-6.el7.x86_64.rpm                                                                                 |  32 kB  00:00:00     
(2/38): bash-completion-2.1-8.el7.noarch.rpm                                                                             |  87 kB  00:00:00     
(3/38): net-tools-2.0-0.25.20131004git.el7.x86_64.rpm                                                                    | 306 kB  00:00:00     
(4/38): perl-Carp-1.26-244.el7.noarch.rpm                                                                                |  19 kB  00:00:00     
(5/38): perl-Exporter-5.68-3.el7.noarch.rpm                                                                              |  28 kB  00:00:00     
(6/38): perl-File-Path-2.09-2.el7.noarch.rpm                                                                             |  26 kB  00:00:00     
(7/38): perl-File-Temp-0.23.01-3.el7.noarch.rpm                                                                          |  56 kB  00:00:00     
(8/38): perl-Encode-2.51-7.el7.x86_64.rpm                                                                                | 1.5 MB  00:00:00     
(9/38): perl-Filter-1.49-3.el7.x86_64.rpm                                                                                |  76 kB  00:00:00     
(10/38): perl-HTTP-Tiny-0.033-3.el7.noarch.rpm                                                                           |  38 kB  00:00:00     
(11/38): perl-Getopt-Long-2.40-3.el7.noarch.rpm                                                                          |  56 kB  00:00:00     
(12/38): perl-Pod-Perldoc-3.20-4.el7.noarch.rpm                                                                          |  87 kB  00:00:00     
(13/38): perl-Pod-Simple-3.28-4.el7.noarch.rpm                                                                           | 216 kB  00:00:00     
(14/38): perl-PathTools-3.40-5.el7.x86_64.rpm                                                                            |  82 kB  00:00:00     
(15/38): perl-Pod-Usage-1.63-3.el7.noarch.rpm                                                                            |  27 kB  00:00:00     
(16/38): perl-Scalar-List-Utils-1.27-248.el7.x86_64.rpm                                                                  |  36 kB  00:00:00     
Public key for perl-5.16.3-299.el7_9.x86_64.rpm is not installed
(17/38): perl-5.16.3-299.el7_9.x86_64.rpm                                                                                | 8.0 MB  00:00:01     
(18/38): perl-Pod-Escapes-1.04-299.el7_9.noarch.rpm                                                                      |  52 kB  00:00:00     
(19/38): perl-Socket-2.010-5.el7.x86_64.rpm                                                                              |  49 kB  00:00:00     
(20/38): perl-Storable-2.45-3.el7.x86_64.rpm                                                                             |  77 kB  00:00:00     
(21/38): perl-Time-HiRes-1.9725-3.el7.x86_64.rpm                                                                         |  45 kB  00:00:00     
(22/38): perl-Text-ParseWords-3.29-4.el7.noarch.rpm                                                                      |  14 kB  00:00:00     
(23/38): perl-Time-Local-1.2300-2.el7.noarch.rpm                                                                         |  24 kB  00:00:00     
(24/38): perl-constant-1.27-2.el7.noarch.rpm                                                                             |  19 kB  00:00:00     
(25/38): perl-podlators-2.5.1-3.el7.noarch.rpm                                                                           | 112 kB  00:00:00     
(26/38): perl-parent-0.225-244.el7.noarch.rpm                                                                            |  12 kB  00:00:00     
(27/38): perl-threads-shared-1.43-6.el7.x86_64.rpm                                                                       |  39 kB  00:00:00     
(28/38): perl-macros-5.16.3-299.el7_9.x86_64.rpm                                                                         |  44 kB  00:00:00     
(29/38): psmisc-22.20-17.el7.x86_64.rpm                                                                                  | 141 kB  00:00:00     
(30/38): perl-libs-5.16.3-299.el7_9.x86_64.rpm                                                                           | 690 kB  00:00:00     
(31/38): perl-threads-1.87-4.el7.x86_64.rpm                                                                              |  49 kB  00:00:00     
(32/38): tree-1.6.0-10.el7.x86_64.rpm                                                                                    |  46 kB  00:00:00     
(33/38): vim-enhanced-7.4.629-8.el7_9.x86_64.rpm                                                                         | 1.1 MB  00:00:00     
(34/38): vim-filesystem-7.4.629-8.el7_9.x86_64.rpm                                                                       |  11 kB  00:00:00     
(35/38): which-2.20-7.el7.x86_64.rpm                                                                                     |  41 kB  00:00:00     
(36/38): wget-1.14-18.el7_6.1.x86_64.rpm                                                                                 | 547 kB  00:00:00     
(37/38): vim-common-7.4.629-8.el7_9.x86_64.rpm                                                                           | 5.9 MB  00:00:00     
(38/38): groff-base-1.22.2-8.el7.x86_64.rpm                                                                              | 942 kB  00:00:00     
------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                           7.0 MB/s |  20 MB  00:00:02     
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
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : gpm-libs-1.20.7-6.el7.x86_64                                                                                                1/38 
  Installing : 2:vim-filesystem-7.4.629-8.el7_9.x86_64                                                                                     2/38 
  Installing : 2:vim-common-7.4.629-8.el7_9.x86_64                                                                                         3/38 
  Installing : which-2.20-7.el7.x86_64                                                                                                     4/38 
install-info: No such file or directory for /usr/share/info/which.info.gz
  Installing : groff-base-1.22.2-8.el7.x86_64                                                                                              5/38 
  Installing : 1:perl-parent-0.225-244.el7.noarch                                                                                          6/38 
  Installing : perl-HTTP-Tiny-0.033-3.el7.noarch                                                                                           7/38 
  Installing : perl-podlators-2.5.1-3.el7.noarch                                                                                           8/38 
  Installing : perl-Pod-Perldoc-3.20-4.el7.noarch                                                                                          9/38 
  Installing : 1:perl-Pod-Escapes-1.04-299.el7_9.noarch                                                                                   10/38 
  Installing : perl-Encode-2.51-7.el7.x86_64                                                                                              11/38 
  Installing : perl-Text-ParseWords-3.29-4.el7.noarch                                                                                     12/38 
  Installing : perl-Pod-Usage-1.63-3.el7.noarch                                                                                           13/38 
  Installing : 4:perl-macros-5.16.3-299.el7_9.x86_64                                                                                      14/38 
  Installing : perl-Storable-2.45-3.el7.x86_64                                                                                            15/38 
  Installing : perl-Exporter-5.68-3.el7.noarch                                                                                            16/38 
  Installing : perl-constant-1.27-2.el7.noarch                                                                                            17/38 
  Installing : perl-Socket-2.010-5.el7.x86_64                                                                                             18/38 
  Installing : perl-Time-Local-1.2300-2.el7.noarch                                                                                        19/38 
  Installing : perl-Carp-1.26-244.el7.noarch                                                                                              20/38 
  Installing : perl-PathTools-3.40-5.el7.x86_64                                                                                           21/38 
  Installing : perl-Scalar-List-Utils-1.27-248.el7.x86_64                                                                                 22/38 
  Installing : 1:perl-Pod-Simple-3.28-4.el7.noarch                                                                                        23/38 
  Installing : perl-File-Temp-0.23.01-3.el7.noarch                                                                                        24/38 
  Installing : perl-File-Path-2.09-2.el7.noarch                                                                                           25/38 
  Installing : perl-threads-shared-1.43-6.el7.x86_64                                                                                      26/38 
  Installing : perl-threads-1.87-4.el7.x86_64                                                                                             27/38 
  Installing : 4:perl-Time-HiRes-1.9725-3.el7.x86_64                                                                                      28/38 
  Installing : perl-Filter-1.49-3.el7.x86_64                                                                                              29/38 
  Installing : 4:perl-libs-5.16.3-299.el7_9.x86_64                                                                                        30/38 
  Installing : perl-Getopt-Long-2.40-3.el7.noarch                                                                                         31/38 
  Installing : 4:perl-5.16.3-299.el7_9.x86_64                                                                                             32/38 
  Installing : 2:vim-enhanced-7.4.629-8.el7_9.x86_64                                                                                      33/38 
  Installing : psmisc-22.20-17.el7.x86_64                                                                                                 34/38 
  Installing : wget-1.14-18.el7_6.1.x86_64                                                                                                35/38 
install-info: No such file or directory for /usr/share/info/wget.info.gz
  Installing : 1:bash-completion-2.1-8.el7.noarch                                                                                         36/38 
  Installing : tree-1.6.0-10.el7.x86_64                                                                                                   37/38 
  Installing : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                  38/38 
  Verifying  : perl-HTTP-Tiny-0.033-3.el7.noarch                                                                                           1/38 
  Verifying  : perl-threads-shared-1.43-6.el7.x86_64                                                                                       2/38 
  Verifying  : perl-Storable-2.45-3.el7.x86_64                                                                                             3/38 
  Verifying  : groff-base-1.22.2-8.el7.x86_64                                                                                              4/38 
  Verifying  : perl-Exporter-5.68-3.el7.noarch                                                                                             5/38 
  Verifying  : perl-constant-1.27-2.el7.noarch                                                                                             6/38 
  Verifying  : 2:vim-enhanced-7.4.629-8.el7_9.x86_64                                                                                       7/38 
  Verifying  : 4:perl-macros-5.16.3-299.el7_9.x86_64                                                                                       8/38 
  Verifying  : perl-PathTools-3.40-5.el7.x86_64                                                                                            9/38 
  Verifying  : 1:perl-parent-0.225-244.el7.noarch                                                                                         10/38 
  Verifying  : perl-Socket-2.010-5.el7.x86_64                                                                                             11/38 
  Verifying  : which-2.20-7.el7.x86_64                                                                                                    12/38 
  Verifying  : 2:vim-filesystem-7.4.629-8.el7_9.x86_64                                                                                    13/38 
  Verifying  : perl-File-Temp-0.23.01-3.el7.noarch                                                                                        14/38 
  Verifying  : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                  15/38 
  Verifying  : 1:perl-Pod-Simple-3.28-4.el7.noarch                                                                                        16/38 
  Verifying  : tree-1.6.0-10.el7.x86_64                                                                                                   17/38 
  Verifying  : perl-Time-Local-1.2300-2.el7.noarch                                                                                        18/38 
  Verifying  : 1:perl-Pod-Escapes-1.04-299.el7_9.noarch                                                                                   19/38 
  Verifying  : perl-Carp-1.26-244.el7.noarch                                                                                              20/38 
  Verifying  : 1:bash-completion-2.1-8.el7.noarch                                                                                         21/38 
  Verifying  : 2:vim-common-7.4.629-8.el7_9.x86_64                                                                                        22/38 
  Verifying  : perl-Scalar-List-Utils-1.27-248.el7.x86_64                                                                                 23/38 
  Verifying  : perl-Pod-Usage-1.63-3.el7.noarch                                                                                           24/38 
  Verifying  : perl-Encode-2.51-7.el7.x86_64                                                                                              25/38 
  Verifying  : perl-Pod-Perldoc-3.20-4.el7.noarch                                                                                         26/38 
  Verifying  : perl-podlators-2.5.1-3.el7.noarch                                                                                          27/38 
  Verifying  : 4:perl-5.16.3-299.el7_9.x86_64                                                                                             28/38 
  Verifying  : perl-File-Path-2.09-2.el7.noarch                                                                                           29/38 
  Verifying  : perl-threads-1.87-4.el7.x86_64                                                                                             30/38 
  Verifying  : 4:perl-Time-HiRes-1.9725-3.el7.x86_64                                                                                      31/38 
  Verifying  : gpm-libs-1.20.7-6.el7.x86_64                                                                                               32/38 
  Verifying  : perl-Filter-1.49-3.el7.x86_64                                                                                              33/38 
  Verifying  : perl-Getopt-Long-2.40-3.el7.noarch                                                                                         34/38 
  Verifying  : perl-Text-ParseWords-3.29-4.el7.noarch                                                                                     35/38 
  Verifying  : wget-1.14-18.el7_6.1.x86_64                                                                                                36/38 
  Verifying  : 4:perl-libs-5.16.3-299.el7_9.x86_64                                                                                        37/38 
  Verifying  : psmisc-22.20-17.el7.x86_64                                                                                                 38/38 

Installed:
  bash-completion.noarch 1:2.1-8.el7     net-tools.x86_64 0:2.0-0.25.20131004git.el7  psmisc.x86_64 0:22.20-17.el7  tree.x86_64 0:1.6.0-10.el7 
  vim-enhanced.x86_64 2:7.4.629-8.el7_9  wget.x86_64 0:1.14-18.el7_6.1               

Dependency Installed:
  gpm-libs.x86_64 0:1.20.7-6.el7                 groff-base.x86_64 0:1.22.2-8.el7                   perl.x86_64 4:5.16.3-299.el7_9             
  perl-Carp.noarch 0:1.26-244.el7                perl-Encode.x86_64 0:2.51-7.el7                    perl-Exporter.noarch 0:5.68-3.el7          
  perl-File-Path.noarch 0:2.09-2.el7             perl-File-Temp.noarch 0:0.23.01-3.el7              perl-Filter.x86_64 0:1.49-3.el7            
  perl-Getopt-Long.noarch 0:2.40-3.el7           perl-HTTP-Tiny.noarch 0:0.033-3.el7                perl-PathTools.x86_64 0:3.40-5.el7         
  perl-Pod-Escapes.noarch 1:1.04-299.el7_9       perl-Pod-Perldoc.noarch 0:3.20-4.el7               perl-Pod-Simple.noarch 1:3.28-4.el7        
  perl-Pod-Usage.noarch 0:1.63-3.el7             perl-Scalar-List-Utils.x86_64 0:1.27-248.el7       perl-Socket.x86_64 0:2.010-5.el7           
  perl-Storable.x86_64 0:2.45-3.el7              perl-Text-ParseWords.noarch 0:3.29-4.el7           perl-Time-HiRes.x86_64 4:1.9725-3.el7      
  perl-Time-Local.noarch 0:1.2300-2.el7          perl-constant.noarch 0:1.27-2.el7                  perl-libs.x86_64 4:5.16.3-299.el7_9        
  perl-macros.x86_64 4:5.16.3-299.el7_9          perl-parent.noarch 1:0.225-244.el7                 perl-podlators.noarch 0:2.5.1-3.el7        
  perl-threads.x86_64 0:1.87-4.el7               perl-threads-shared.x86_64 0:1.43-6.el7            vim-common.x86_64 2:7.4.629-8.el7_9        
  vim-filesystem.x86_64 2:7.4.629-8.el7_9        which.x86_64 0:2.20-7.el7                         

Complete!

 

 

2.3、在容器内安装配置nginx,生成业务数据,设置服务前台运行

## 安装epel源
[root@502a7a7faae8 /]# wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
--2023-04-24 14:23:54--  https://mirrors.aliyun.com/repo/epel-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 120.226.58.184, 120.226.58.182, 120.226.58.185, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|120.226.58.184|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 664 [application/octet-stream]
Saving to: \'/etc/yum.repos.d/epel.repo\'

100%[======================================================================================================>] 664         --.-K/s   in 0s      

2023-04-24 14:23:54 (124 MB/s) - \'/etc/yum.repos.d/epel.repo\' saved [664/664]

[root@502a7a7faae8 /]# yum makecache fast
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                     | 3.6 kB  00:00:00     
epel                                                                                                                     | 4.7 kB  00:00:00     
extras                                                                                                                   | 2.9 kB  00:00:00     
updates                                                                                                                  | 2.9 kB  00:00:00     
(1/3): epel/x86_64/group_gz                                                                                              |  99 kB  00:00:00     
(2/3): epel/x86_64/updateinfo                                                                                            | 1.0 MB  00:00:00     
(3/3): epel/x86_64/primary_db                                               

docker镜像管理基础(代码片段)

docker镜像管理基础文章目录docker镜像管理基础镜像的概念docker镜像层docker存储驱动AUFSOverlayFSDeviceMapperdockerregistrydocker镜像的制作DockerHubdocker镜像的获取镜像的生成基于容器制作镜像镜像的概念镜像可以理解为应用程序的集装箱&#x... 查看详情

docker镜像管理基础与基于容器的镜像制作示例(代码片段)

一、Docker镜像  Docker镜像是启动Docker容器的一个非常重要的组件。Docker各组件之间的关系如图:  Docker镜像含有启动容器所需要的文件系统及其内容,因此Docker镜像用于创建并启动容器。并且Docker镜像是采用分层构建,联合... 查看详情

docker镜像的制作上传拉取和部署(代码片段)

Docker镜像的制作、上传、拉取和部署一、镜像(images)1.什么是镜像?2.镜像的组成和用途(1)Dockerfile(2)scratch(3)一个完整的操作系统需要:3.为什么要自己制作镜像?二、镜像制作... 查看详情

docker镜像制作案例——关于kafka-eagle-2.0.8(efak)版本的kafka管理工具实现镜像制作及发布(代码片段)

...款kafka集群常用的管理工具kafka-eagle,实现kafka-eagle的docker镜像制作及发布,由于其官方没有提供docker镜像,我们自行构建一个镜像并发布运行。以下是其镜像制作的详细过程。效果如下:正文下载kafka-eagle软件包并上传... 查看详情

dockerdockerfile编辑和镜像制作(代码片段)

镜像分层和镜像的创建一、镜像分层二、镜像挂载1、docker数据卷2、数据卷容器三、dockerfile文件编辑和镜像制作1、编辑Dockerlife文件和所需脚本2、开始创建镜像3、登陆验证一、镜像分层Docker镜像含有启动容器所需要的文件系统... 查看详情

dockerdockerfile编辑和镜像制作(代码片段)

镜像分层和镜像的创建一、镜像分层二、镜像挂载1、docker数据卷2、数据卷容器三、dockerfile文件编辑和镜像制作1、编辑Dockerlife文件和所需脚本2、开始创建镜像3、登陆验证一、镜像分层Docker镜像含有启动容器所需要的文件系统... 查看详情

docker镜像管理基础(代码片段)

docker镜像管理基础文章目录docker镜像管理基础镜像的概念docker镜像层docker存储驱动AUFSOverlayFSDeviceMapperdockerregistrydocker镜像的制作DockerHubdocker镜像的获取镜像的生成基于容器制作镜像镜像的概念镜像可以理解为应用程序的集装箱&#x... 查看详情

docker-镜像管理基础(代码片段)

Docker镜像Docker镜像含有启动容器所需要的文件系统及其内容,因此,其用于创建并启动docker容器采用分层构建机制,最底层为bootfs,其之为rootfsbootfs:用于系统引导的文件系统,包括bootloader和kernel,容器启动完成后会被卸载以节... 查看详情

docker镜像制作常用官方基础系统镜像的选择(代码片段)

Docker镜像为了满足业务需求,我们通常需要基于官方Linux系统镜像制作私有镜像选择合适的的Docker官方基础Linux系统镜像成为了首先需要考虑的事情Docker镜像是只读的docker容器模板,封装着启动docker容器所需的文件系统结... 查看详情

docker分布式lnmp镜像制作(代码片段)

docker分布式lnmp镜像制作一、docker分布式lnmp镜像制作1、运行Nginx、MySQL、PHP容器2、修改Nginx配置文件和PHP文件4、进行测试虚拟机输入localhost/index.php本机输入192.168.184.70/index.php(我虚拟机地址是192.168.184.70)一、docker分布式... 查看详情

docker镜像创建私有仓库搭建和数据管理(代码片段)

Docker镜像的创建方法Docker镜像除了是Docker的核心技术之外也是应用发布的标准格式。一个完整的Docker镜像可以支撑一个Docker容器的运行,在Docker的整个使用过程中,进入一个已经定型的容器之后,就可以在容器中进行操作,最常... 查看详情

docker镜像管理基础(代码片段)

docker镜像管理基础镜像的概念镜像可以理解为应用程序的集装箱,而docker用来装卸集装箱。docker镜像含有启动容器所需要的文件系统及其内容,因此,其用于创建并启动容器。docker镜像采用分层构建机制,最底层为bootfs,其上为... 查看详情

docker基本管理(镜像容器)(代码片段)

目录一、Docker概述1、容器化2、Docker与虚拟机的区别3、Docker核心概念4、Linux文件系统和Docker文件系统的区别二、安装Docker三、Docker镜像操作1、搜索镜像2、获取镜像3、镜像加速下载4、查看镜像信息5、查看下载的镜像文件信息6、... 查看详情

java程序制作docker镜像推荐方案(代码片段)

文章目录背景制作条件Dockerfile指令:实践步骤使用官网提供的基础镜像作为镜像基础设定容器的正确的时间和时区容器中采用非root用户权限启动应用程序DockerFile样例COPY与ADD区别举个栗子背景随着我们分布式的观念在各个领... 查看详情

关于制作docker镜像?|dockerfile快速开始(代码片段)

文章目录一、关于制作Docker镜像?🐋1.Docker镜像的构建原理和方式1.1Docker镜像的构建方式使用场景和选型二、Dockerfile快速开始什么是DockerfileDockerfile的基本结构Dockerfile常用的指令FROM命令LABELWORKDIRRUNCOPYCMDEXPOSEENTRYPOINTCMD与E... 查看详情

docker系统笔记-03镜像的创建管理和发布(代码片段)

镜像的获取pullfromregistry(online)从registry拉取public(公有)private(私有)buildfromDockerfile(online)从Dockerfile构建loadfromfile(offline)文件导入(离线)镜像的基本操作dockerimage查看dockerim 查看详情

容器化工具--------docker的数据管理和镜像的创建(代码片段)

...间共享)三、容器互联(使用centos镜像)四、Docker镜像1、镜像介绍2、镜像创建的方法3、基于已有镜像创建4、基于本地模板创建5、基于Dockerfile创建(关键)(1)联合文件系统Unio 查看详情

docker:docker镜像管理(代码片段)

一、基本介绍docker镜像是容器启动的基础,镜像里面包含容器启动所需要的文件系统及其内容。docker镜像采用分层构建的机制,这种分层大致分为两部分,一部分是最底层的引导文件系统bootfs,类型有aufs,btffs或者overlay2等;另... 查看详情