Linux下基于Dockerfile构建镜像应用(1)

目录

基于已有容器创建镜像

Dockerfile构建SSHD镜像

构建镜像

测试容器  可以登陆

Dockerfile构建httpd镜像

构建镜像

测试容器

 Dockerfile构建nginx镜像

构建镜像


概述:

Docker 镜像是Docker容器技术中的核心,也是应用打包构建发布的标准格式。一个完整的镜像可以支撑多个容器的运行,在Docker的整个使用过程中,进入一个已经定型的容器之后,就可以在容器中进行操作,最常见的操作就是在容器中安装应用服务。

如果想要把已经安装的服务容器进行迁移,就需要把环境以及部署的服务生成新的镜像。

程序打包方式:

  1. 打包成Tar包
  2. 打包成rpm包
  3. 打包成镜像

构建方式

1、基于已有的容器创建镜像

2、基于本地模板创建镜像

3、基于Dockerfile创建镜像

基于已有容器创建镜像

基于现有镜像创建主要使用 docker commit 命令,即把一个容器里面运行的程序以及该程序的运行环境打包起来生成新的镜像。

命令格式:

docker commit [选项] 容器ID/名称 仓库名称:[标签] 

常用选项:

  1. -m 说明信息;
  2. -a 作者信息;
  3. -p 生成过程中停止容器的运行。

首先启动一个镜像,在容器里做相应的修改,然后将修改后的容器提交为新的镜像。需要记住该容器的ID号。

[root@localhost ~]# cat centos-7-x86_64.tar.gz |docker import - centos:7

sha256:790d0b6eb9de3d7ba8df7d91a54d236b381f4800ac751205a1fb6b77cc0c7efd

[root@localhost sshd]# docker run -it centos:7 /bin/bash

WARNING: IPv4 forwarding is disabled. Networking will not work.

[root@d80919f3c00c /]# ls

bin   dev  fastboot  lib    lost+found  mnt  proc  run   srv  tmp  var

boot  etc  home      lib64  media       opt  root  sbin  sys  usr

[root@d80919f3c00c /]# touch lifenghai                  创建测试文件

[root@d80919f3c00c /]# ls

bin   dev  fastboot  lib    lifenghai   media  opt   root  sbin  sys  usr

boot  etc  home      lib64  lost+found  mnt    proc  run   srv   tmp  var

[root@d80919f3c00c /]# exit

exit

[root@localhost sshd]# docker commit -m "crushlinux test images" -a "crushlinux" d80919f3c00c centos7:ddd

sha256:595d590702ffc0ca7e23f11f552266c924261c5966f7634de96ba7dfe6a547c3

[root@localhost sshd]# docker images centos7:ddd

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

centos7             ddd                 595d590702ff        25 seconds ago      589 MB

[root@localhost sshd]# docker run -it centos7:ddd /bin/bash

WARNING: IPv4 forwarding is disabled. Networking will not work.

[root@14ad9a706c54 /]# ls

bin   dev  fastboot  lib    lifenghai   media  opt   root  sbin  sys  usr

boot  etc  home      lib64  lost+found  mnt    proc  run   srv   tmp  var

这是一个Docker命令,用于将一个容器的更改保存为新的镜像。具体解释如下:

  • docker commit:Docker命令,用于提交容器的更改。
  • -m "crushlinux test images":使用-m参数指定提交的消息,这里是"crushlinux test images"。
  • -a "crushlinux":使用-a参数指定作者,这里是"crushlinux"。
  • d281f905fb30:容器的ID或名称,表示要提交更改的容器。
  • centos7:new:新镜像的名称和标签,这里是"centos7:new"。

因此,该命令的意思是将容器ID为d281f905fb30的容器的更改保存为名为"centos7:new"的新镜像,并指定了提交消息为"crushlinux test images",作者为"crushlinux"。

Dockerfile构建SSHD镜像

关闭防火墙规则

iptables -F
 setenforce 0
 systemctl stop firewalld

修改配置

[root@localhost ~]# cat /etc/resolv.conf

# Generated by NetworkManager

nameserver 8.8.8.8

search localdomain

创建备用目录

[root@localhost ~]# mkdir sshd

获取密钥

[root@localhost ~]# ssh-keygen

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Created directory '/root/.ssh'.

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

SHA256:6j2zE3PzgNt4sQdpeR0BUSO4NCrtnissqN4xHJZVoLE root@localhost.localdomain

The key's randomart image is:

+---[RSA 2048]----+

|   . ...   .++o  |

|    + .   +  ... |

|   E . . o o   . |

|    o . o .   .  |

|   +   oS. o . . |

|  o .  .= X . .  |

|   = ... X O     |

|  o +.o.O + o    |

|oo . ...+B .     |

+----[SHA256]-----+

拷贝文件

[root@localhost ~]# cp .ssh/id_rsa.pub sshd/

[root@localhost ~]# cd sshd/

[root@localhost ~]# ll

总用量 591996

-rw-------. 1 root root      1415 7月  31 19:02 anaconda-ks.cfg

-rw-r--r--. 1 root root 221692852 7月  17 2020 centos-7-x86_64.tar.gz

-rw-r--r--. 1 root root 238594048 7月  31 14:26 centos-exp

-rw-------. 1 root root 145905152 7月  31 14:36 nginx-images

drwxr-xr-x. 2 root root        47 8月   2 13:57 sshd

导入镜像

[root@localhost ~]# cat centos-7-x86_64.tar.gz |docker import - centos:7

sha256:790d0b6eb9de3d7ba8df7d91a54d236b381f4800ac751205a1fb6b77cc0c7efd

编写Dockerfile文件

[root@localhost sshd]# vim Dockerfile

#基于的基础镜像

FROM centos:7

#镜像作者信息

MAINTAINER Crushlinux <crushlinux@163.com>

#镜像执行的命令

RUN yum -y install openssh-server net-tools openssh-devel lsof telnet

RUN sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config

RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key

RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key

ADD id_rsa.pub /root/.ssh/authorized_keys

#定义时区

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

#开启 22 端口

EXPOSE 22

#启动容器时执行指令

CMD ["/usr/sbin/sshd" , "-D"]

~                                                                                                      

~           

重启

[root@localhost sshd]# systemctl restart network

[root@localhost sshd]# systemctl restart docker

构建镜像

[root@localhost sshd]#  docker build -t sshd:new .

Sending build context to Docker daemon 3.584 kB

Step 1/9 : FROM centos:7

 ---> 790d0b6eb9de

Step 2/9 : MAINTAINER Crushlinux <crushlinux@163.com>

 ---> Using cache

 ---> f5d4ad40d1df

Step 3/9 : RUN yum -y install openssh-server net-tools openssh-devel lsof telnet

 ---> Running in bdb9cc0dfb6c


Loaded plugins: fastestmirror

Determining fastest mirrors

 * base: mirrors.bfsu.edu.cn

 * extras: mirrors.ustc.edu.cn

 * updates: mirrors.ustc.edu.cn

No package openssh-devel available.

Resolving Dependencies

--> Running transaction check

---> Package lsof.x86_64 0:4.87-4.el7 will be updated

---> Package lsof.x86_64 0:4.87-6.el7 will be an update

---> Package net-tools.x86_64 0:2.0-0.25.20131004git.el7 will be installed

---> Package openssh-server.x86_64 0:6.6.1p1-25.el7_2 will be updated

---> Package openssh-server.x86_64 0:7.4p1-22.el7_9 will be an update

--> Processing Dependency: openssh = 7.4p1-22.el7_9 for package: openssh-server-7.4p1-22.el7_9.x86_64

--> Processing Dependency: libcrypto.so.10(OPENSSL_1.0.2)(64bit) for package: openssh-server-7.4p1-22.el7_9.x86_64

---> Package telnet.x86_64 1:0.17-59.el7 will be updated

---> Package telnet.x86_64 1:0.17-66.el7 will be an update

--> Running transaction check

---> Package openssh.x86_64 0:6.6.1p1-25.el7_2 will be updated

--> Processing Dependency: openssh = 6.6.1p1-25.el7_2 for package: openssh-clients-6.6.1p1-25.el7_2.x86_64

---> Package openssh.x86_64 0:7.4p1-22.el7_9 will be an update

---> Package openssl-libs.x86_64 1:1.0.1e-51.el7_2.5 will be updated

--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.1e-51.el7_2.5 for package: 1:openssl-1.0.1e-51.el7_2.5.x86_64

---> Package openssl-libs.x86_64 1:1.0.2k-26.el7_9 will be an update

--> Running transaction check

---> Package openssh-clients.x86_64 0:6.6.1p1-25.el7_2 will be updated

---> Package openssh-clients.x86_64 0:7.4p1-22.el7_9 will be an update

---> Package openssl.x86_64 1:1.0.1e-51.el7_2.5 will be updated

---> Package openssl.x86_64 1:1.0.2k-26.el7_9 will be an update

--> Finished Dependency Resolution


Dependencies Resolved


================================================================================

 Package             Arch       Version                       Repository   Size

================================================================================

Installing:

 net-tools           x86_64     2.0-0.25.20131004git.el7      base        306 k

Updating:

 lsof                x86_64     4.87-6.el7                    base        331 k

 openssh-server      x86_64     7.4p1-22.el7_9                updates     459 k

 telnet              x86_64     1:0.17-66.el7                 updates      64 k

Updating for dependencies:

 openssh             x86_64     7.4p1-22.el7_9                updates     510 k

 openssh-clients     x86_64     7.4p1-22.el7_9                updates     655 k

 openssl             x86_64     1:1.0.2k-26.el7_9             updates     494 k

 openssl-libs        x86_64     1:1.0.2k-26.el7_9             updates     1.2 M


Transaction Summary

================================================================================

Install  1 Package

Upgrade  3 Packages (+4 Dependent packages)


Total download size: 4.0 M

Downloading packages:

Delta RPMs disabled because /usr/bin/applydeltarpm not installed.

warning: /var/cache/yum/x86_64/7/base/packages/lsof-4.87-6.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY

Public key for lsof-4.87-6.el7.x86_64.rpm is not installed

Public key for openssh-server-7.4p1-22.el7_9.x86_64.rpm is not installed

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

 Package    : centos-release-7-2.1511.el7.centos.2.10.x86_64 (installed)

 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

--------------------------------------------------------------------------------

Total                                              622 kB/s | 4.0 MB  00:06     

Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Updating   : 1:openssl-libs-1.0.2k-26.el7_9.x86_64                       1/15

  Updating   : openssh-7.4p1-22.el7_9.x86_64                               2/15

  Updating   : openssh-server-7.4p1-22.el7_9.x86_64                        3/15

warning: /etc/ssh/sshd_config created as /etc/ssh/sshd_config.rpmnew

  Updating   : openssh-clients-7.4p1-22.el7_9.x86_64                       4/15

  Updating   : 1:openssl-1.0.2k-26.el7_9.x86_64                            5/15

  Installing : net-tools-2.0-0.25.20131004git.el7.x86_64                   6/15

  Updating   : lsof-4.87-6.el7.x86_64                                      7/15

  Updating   : 1:telnet-0.17-66.el7.x86_64                                 8/15

  Cleanup    : openssh-clients-6.6.1p1-25.el7_2.x86_64                     9/15

  Cleanup    : openssh-server-6.6.1p1-25.el7_2.x86_64                     10/15

  Cleanup    : openssh-6.6.1p1-25.el7_2.x86_64                            11/15

  Cleanup    : 1:openssl-1.0.1e-51.el7_2.5.x86_64                         12/15

  Cleanup    : 1:openssl-libs-1.0.1e-51.el7_2.5.x86_64                    13/15

  Cleanup    : lsof-4.87-4.el7.x86_64                                     14/15

  Cleanup    : 1:telnet-0.17-59.el7.x86_64                                15/15

  Verifying  : 1:telnet-0.17-66.el7.x86_64                                 1/15

  Verifying  : openssh-server-7.4p1-22.el7_9.x86_64                        2/15

  Verifying  : 1:openssl-libs-1.0.2k-26.el7_9.x86_64                       3/15

  Verifying  : lsof-4.87-6.el7.x86_64                                      4/15

  Verifying  : net-tools-2.0-0.25.20131004git.el7.x86_64                   5/15

  Verifying  : openssh-clients-7.4p1-22.el7_9.x86_64                       6/15

  Verifying  : openssh-7.4p1-22.el7_9.x86_64                               7/15

  Verifying  : 1:openssl-1.0.2k-26.el7_9.x86_64                            8/15

  Verifying  : 1:telnet-0.17-59.el7.x86_64                                 9/15

  Verifying  : openssh-6.6.1p1-25.el7_2.x86_64                            10/15

  Verifying  : 1:openssl-1.0.1e-51.el7_2.5.x86_64                         11/15

  Verifying  : openssh-server-6.6.1p1-25.el7_2.x86_64                     12/15

  Verifying  : openssh-clients-6.6.1p1-25.el7_2.x86_64                    13/15

  Verifying  : lsof-4.87-4.el7.x86_64                                     14/15

  Verifying  : 1:openssl-libs-1.0.1e-51.el7_2.5.x86_64                    15/15


Installed:

  net-tools.x86_64 0:2.0-0.25.20131004git.el7                                   


Updated:

  lsof.x86_64 0:4.87-6.el7          openssh-server.x86_64 0:7.4p1-22.el7_9      

  telnet.x86_64 1:0.17-66.el7      


Dependency Updated:

  openssh.x86_64 0:7.4p1-22.el7_9     openssh-clients.x86_64 0:7.4p1-22.el7_9   

  openssl.x86_64 1:1.0.2k-26.el7_9    openssl-libs.x86_64 1:1.0.2k-26.el7_9     


Complete!

 ---> 4d1711b1891c

Removing intermediate container bdb9cc0dfb6c

Step 4/9 : RUN sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config

 ---> Running in c6bcc01f445e


 ---> 20b01ccf2a71

Removing intermediate container c6bcc01f445e

Step 5/9 : RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key

 ---> Running in 8d573e2d3e45


Generating public/private rsa key pair.

Your identification has been saved in /etc/ssh/ssh_host_rsa_key.

Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub.

The key fingerprint is:

SHA256:Q9t9zoZ4iE/eCmeKuyUqmUt1IRvPo34wrWN5wbo8ypE root@bdb9cc0dfb6c

The key's randomart image is:

+---[RSA 2048]----+

|                 |

|                 |

|    o . .        |

|     * o o .     |

|    oo= S . . .  |

|   ooo+. o o =   |

|  Eo.*..+ * o +  |

| o++B.o+ O o .   |

|  +==*+o. +..    |

+----[SHA256]-----+

Enter passphrase (empty for no passphrase): Enter same passphrase again:  ---> 14dd7eb2256f

Removing intermediate container 8d573e2d3e45

Step 6/9 : ADD id_rsa.pub /root/.ssh/authorized_keys

 ---> 99984eb1e50e

Removing intermediate container 369022575e01

Step 7/9 : RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

 ---> Running in b0056bbc027e


 ---> 950f0c260a79

Removing intermediate container b0056bbc027e

Step 8/9 : EXPOSE 22

 ---> Running in 190b29e65718

 ---> c6a476cb31b4

Removing intermediate container 190b29e65718

Step 9/9 : CMD /usr/sbin/sshd -D

 ---> Running in 0b76956add3a

 ---> a600eb2f7bad

Removing intermediate container 0b76956add3a

Successfully built a600eb2f7bad

                   

测试容器  可以登陆

[root@localhost sshd]#  docker images sshd:new

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

sshd                new                 a600eb2f7bad        3 minutes ago       821 MB

[root@localhost sshd]# docker run -d -p 2222:22 --name sshd-test --restart=always sshd:new

61a2bbb409288f6d1e0c95dfe8ef9b732b77bcd35129972700d181fefa08631e

[root@localhost sshd]# ssh localhost -p 2222

The authenticity of host '[localhost]:2222 ([::1]:2222)' can't be established.

RSA key fingerprint is SHA256:Q9t9zoZ4iE/eCmeKuyUqmUt1IRvPo34wrWN5wbo8ypE.

RSA key fingerprint is MD5:1e:97:2c:02:4d:35:1e:3f:68:a0:30:9c:cc:53:a2:cf.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '[localhost]:2222' (RSA) to the list of known hosts.

[root@61a2bbb40928 ~]#

[root@61a2bbb40928 ~]# exit

登出

Connection to localhost closed.

Dockerfile构建httpd镜像

创建工作目录

[root@localhost ~]# mkdir httpd

[root@localhost ~]# cd httpd/

编写Dockerfile文件

[root@localhost httpd]# vim Dockerfile

[root@localhost httpd]#  cat Dockerfile

FROM centos:7

MAINTAINER hhh <hhh@163.com>

RUN yum -y install httpd

RUN echo "crushlinux" >/var/www/html/index.html

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

EXPOSE 80

CMD ["httpd","-DFOREGROUND"]

构建镜像

[root@localhost httpd]# docker build -t httpd:new .

Sending build context to Docker daemon 2.048 kB

Step 1/7 : FROM centos:7

 ---> 790d0b6eb9de

Step 2/7 : MAINTAINER hhh <hhh@163.com>

 ---> Using cache

 ---> 25eef094ceba

Step 3/7 : RUN yum -y install httpd

 ---> Running in 8324e3b4b5c7

Loaded plugins: fastestmirror

Determining fastest mirrors

 * base: mirrors.bfsu.edu.cn

 * extras: mirrors.bfsu.edu.cn

 * updates: mirrors.bfsu.edu.cn

Resolving Dependencies

--> Running transaction check

---> Package httpd.x86_64 0:2.4.6-40.el7.centos.1 will be updated

---> Package httpd.x86_64 0:2.4.6-99.el7.centos.1 will be an update

--> Processing Dependency: httpd-tools = 2.4.6-99.el7.centos.1 for package: httpd-2.4.6-99.el7.centos.1.

--> Running transaction check

---> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos.1 will be updated

---> Package httpd-tools.x86_64 0:2.4.6-99.el7.centos.1 will be an update

--> Finished Dependency Resolution

Dependencies Resolved

================================================================================

 Package           Arch         Version                     Repository     Size

================================================================================

Updating:

 httpd             x86_64       2.4.6-99.el7.centos.1       updates       2.7 M

Updating for dependencies:

 httpd-tools       x86_64       2.4.6-99.el7.centos.1       updates        94 k

Transaction Summary

================================================================================

Upgrade  1 Package (+1 Dependent package)

Total download size: 2.8 M

Downloading packages:

Delta RPMs disabled because /usr/bin/applydeltarpm not installed.

Public key for httpd-tools-2.4.6-99.el7.centos.1.x86_64.rpm is not installed

warning: /var/cache/yum/x86_64/7/updates/packages/httpd-tools-2.4.6-99.el7.centos.1.x86_64.rpm: Header V

--------------------------------------------------------------------------------

Total                                              1.6 MB/s | 2.8 MB  00:01     

Retrieving key from file:///etc/pki/rpm-gpg/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

 Package    : centos-release-7-2.1511.el7.centos.2.10.x86_64 (installed)

 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Updating   : httpd-tools-2.4.6-99.el7.centos.1.x86_64                     1/4

  Updating   : httpd-2.4.6-99.el7.centos.1.x86_64                           2/4

  Cleanup    : httpd-2.4.6-40.el7.centos.1.x86_64                           3/4

  Cleanup    : httpd-tools-2.4.6-40.el7.centos.1.x86_64                     4/4

  Verifying  : httpd-2.4.6-99.el7.centos.1.x86_64                           1/4

  Verifying  : httpd-tools-2.4.6-99.el7.centos.1.x86_64                     2/4

  Verifying  : httpd-2.4.6-40.el7.centos.1.x86_64                           3/4

  Verifying  : httpd-tools-2.4.6-40.el7.centos.1.x86_64                     4/4

Updated:

  httpd.x86_64 0:2.4.6-99.el7.centos.1                                          

Dependency Updated:

  httpd-tools.x86_64 0:2.4.6-99.el7.centos.1                                    

Complete!

 ---> 2214fb4006c9

Removing intermediate container 8324e3b4b5c7

Step 4/7 : RUN echo "crushlinux" >/var/www/html/index.html

 ---> Running in badb364c7e55

 ---> a9b433c350e4

Removing intermediate container badb364c7e55

Step 5/7 : RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

 ---> Running in d0081e48aa43

 ---> ffaf678f3cfc

Removing intermediate container d0081e48aa43

Step 6/7 : EXPOSE 80

 ---> Running in 3bd620f29826

 ---> 89d665eda838

Removing intermediate container 3bd620f29826

Step 7/7 : CMD httpd -DFOREGROUND

 ---> Running in 2dea705ece43

 ---> 7f5e5dc62d40

Removing intermediate container 2dea705ece43

Successfully built 7f5e5dc62d40

查看

[root@localhost httpd]# docker images httpd

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

httpd               new                 7f5e5dc62d40        2 minutes ago       819 MB

测试容器

[root@localhost httpd]# docker run -d -p 8080:80 --name httpd-test --restart=always httpd:new

90bc8641fbefdf722c5d5842931d776bcbef0a6766c66f3fbc92d966d5752460

 Dockerfile构建nginx镜像

建立工作目录

[root@localhost ~]# mkdir nginx

[root@localhost ~]# cd nginx

编写Dockerfile文件

[root@localhost nginx]# vim run.sh

[root@localhost nginx]# cat run.sh

#!/bin/bash

/usr/local/nginx/sbin/nginx

[root@localhost nginx]# cat Dockerfile

#基于的基础镜像

FROM centos:7

#镜像作者信息

MAINTAINER hhh <hhh@163.com>

#安装相关依赖包

RUN yum install -y wget proc-devel net-tools gcc zlib zlib-devel make openssl-devel

#下载并解压nginx源码包

RUN wget http://nginx.org/download/nginx-1.19.0.tar.gz && tar zxf nginx-1.19.0.tar.gz

#编译安装nginx

RUN cd nginx-1.19.0 && ./configure --prefix=/usr/local/nginx && make && make install

#开启 80 和 443 端口

EXPOSE 80

#修改 Nginx 配置文件,以非 daemon 方式启动

RUN echo "daemon off;">>/usr/local/nginx/conf/nginx.conf

#定义时区

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

#复制服务启动脚本并设置权限

ADD run.sh /run.sh

RUN chmod 775 /run.sh

#启动容器时执行脚本

CMD ["/run.sh"]

构建镜像

[root@localhost nginx]#  docker build -t nginx:new

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/56362.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

史上最细,接口自动化测试框架-Pytest+Allure+Excel整理(代码)

目录&#xff1a;导读 前言一、Python编程入门到精通二、接口自动化项目实战三、Web自动化项目实战四、App自动化项目实战五、一线大厂简历六、测试开发DevOps体系七、常用自动化测试工具八、JMeter性能测试九、总结&#xff08;尾部小惊喜&#xff09; 前言 Allure框架 Allu…

Vue 自定义事件绑定与解绑

绑定自定义事件 说到 Vue 自定义事件&#xff0c;那就需要搞清楚一个问题&#xff0c;为啥有这个玩意。 说到自定义事件之前&#xff0c;需要理解 组件基础的概念。理解了基础概念之后&#xff0c;我们就知道 Vue 的父子之间的通信&#xff0c; 一是 父组件通过 Prop 向子组件…

qt系列-qt6在线安装慢的问题

.\qt-unified-windows-x64-online.exe --mirror https://mirrors.aliyun.com/qt/下载速度飞快

就业并想要长期发展选数字后端还是ic验证?

“就业并想要长期发展选数字后端还是ic验证&#xff1f;” 这是知乎上的一个热点问题&#xff0c;浏览量达到了13,183。看来有不少同学对这个问题感到疑惑。之前更新了数字后端&数字验证的诸多文章&#xff0c;从学习到职业发展&#xff0c;都写过&#xff0c;唯一没有做过…

Mybatis 知识点

Mybatis 知识点 1.1 Mybatis 简介 1.1.1 什么是 Mybatis Mybatis 是一款优秀的持久层框架支持定制化 SQL、存储过程及高级映射Mybatis 几乎避免了所有的 JDBC 代码和手动设置参数以及获取结果集MyBatis 可以使用简单的 XML 或注解来配置和映射原生类型、接口和 Java 的 POJO…

代码随想录算法训练营第三十二天 | 全是没接触过的知识点,要复习

以下题目多次复习 200 岛屿数量未看解答自己编写的青春版重点本题的解题思路&#xff0c;也是之前没有接触过的&#xff0c;四字总结&#xff1a;学会感染&#xff01; 题解的代码日后复习重新编写 32 最长有效括号未看解答自己编写的青春版重点这道题&#xff0c;动态规划的思…

小鹏遭遇“动荡”,自动驾驶副总裁吴新宙离职,现已完成团队过渡

根据最新消息&#xff0c;小鹏汽车的自动驾驶副总裁吴新宙宣布将加入全球GPU芯片巨头英伟达。吴新宙将成为该公司全球副总裁&#xff0c;直接向英伟达全球CEO黄仁勋汇报。小鹏汽车董事长何小鹏和吴新宙本人已在微博上确认该消息&#xff0c;并解释离职原因涉及家庭和多方面因素…

Spark提交流程

客户端通过脚本将任务提交到yarn执行&#xff0c;yarn启动APPMaster&#xff0c;APPMaster启动Driver线程&#xff0c;Driver负责初始化SparkContext并进行任务的切分和分配任务&#xff0c;交给Executor进行计算。

质数(判定质数 分解质因数 筛质数)

这里写目录标题 一、判定质数思路分析代码实现 二、分解质因数思路分析典型题目代码实现 三、质数筛经典题目思路分析1. 朴素筛法2. 埃氏筛法3. 欧拉筛法 一、判定质数 思路分析 由于每个合数的因子是成对出现的&#xff0c;即如果 d d d 是 n n n 的因子&#xff0c;那么 …

Qt实现引导界面UITour

介绍 最近做了一款键鼠自动化&#xff0c;想第一次安装打开后搞一个引导界面&#xff0c;找了好多资料没啥参考&#xff0c;偶然发现qt有引导界面如下图。 Qt整挺好&#xff0c;但是未找到源码&#xff0c;真的不想手撸&#xff0c;(源码找到了但是Qt整起来太复杂,没法拿来直接…

Python系统学习1-2

目录 一、硬件 二、软件&#xff1a;程序文档 三、基础知识 四、python执行过程 五、Pycharm使用技巧 一、硬件 计算机五大部件&#xff1a;运算器&#xff0c;存储器&#xff0c;控制器、输入设备&#xff0c;输出设备。 运算器和控制器 集成在CPU中。 存储&#xff1a…

Qt Creator 11 开放源码集成开发环境新增集成终端和 GitHub Copilot 支持

导读Qt 项目今天发布了 Qt Creator 11&#xff0c;这是一款开源、免费、跨平台 IDE&#xff08;集成开发环境&#xff09;软件的最新稳定版本&#xff0c;适用于 GNU/Linux、macOS 和 Windows 平台。 Qt Creator 11 的亮点包括支持标签、多外壳、颜色和字体的集成终端模拟器&am…

hcip——BGP实验

要求 1.搭建toop 2.地址规划 路由器AS接口地址R11 loop0:1.1.1.1 24 loop1 : 192.168.1.1 24 g0/0/0 12.0.0.1 24 R22 64512 g0/0/0: 12.0.0.2 24 g/0/01: 172.16.0.2 19 g0/0/2: 172.16.96.2 19 R32 64512g0/0/0: 172.16.0.3 19 g0/0/1:1…

在使用Python爬虫时遇到解析错误解决办法汇总

在进行Python爬虫任务时&#xff0c;遇到解析错误是常见的问题之一。解析错误可能是由于网页结构变化、编码问题、XPath选择器错误等原因导致的。为了帮助您解决这个问题&#xff0c;本文将提供一些实用的解决办法&#xff0c;并给出相关的代码示例&#xff0c;希望对您的爬虫任…

实现Feed流的三种模式:拉模式、推模式和推拉结合模式

在互联网产品中&#xff0c;Feed流是一种常见的功能&#xff0c;它可以帮助我们实时获取我们关注的用户的最新动态。Feed流的实现有多种模式&#xff0c;包括拉模式、推模式和推拉结合模式。在本文中&#xff0c;我们将详细介绍这三种模式&#xff0c;并通过Java代码示例来实现…

Centos7 安装man中文版手册

查找man中文安装包&#xff1a; yum search man-pages 安装man-pages-zh-CN.noarch: yum install -y man-pages-zh-CN.noarch

05|Oracle学习(UNIQUE约束)

1. UNIQUE约束介绍 也叫&#xff1a;唯一键约束&#xff0c;用于限定数据表中字段值的唯一性。 1.1 UNIQUE和primary key区别&#xff1a; 主键/联合主键每张表中只有一个。UNIQUE约束可以在一张表中&#xff0c;多个字段中存在。例如&#xff1a;学生的电话、身份证号都是…

091.粉刷房子

一、题目 剑指 Offer II 091. 粉刷房子 - 力扣&#xff08;LeetCode&#xff09; 二、代码 class Solution { public:int minCost(vector<vector<int>>& costs) {int row costs.size();int col costs[0].size();if (row 1)return min(min(costs[0][0], cos…

Mybatis ,Mybatis-plus列表多字段排序,包含sql以及warpper

根据 mybatis 根据多字段排序已经wrapper 根据多字段排序 首先根据咱们返回前端的数据列来规划好排序字段 如下&#xff1a; 这里的字段为返回VO的字段,要转换成数据库字段然后加入到排序中 示例&#xff0c;穿了 surname,cerRank 多字段,然后是倒序 false 首先创建好映射&am…

Python元编程-装饰器介绍、使用

目录 一、Python元编程装饰器介绍 二、装饰器使用 1. 实现认证和授权功能 2.实现缓存功能 3.实现日志输出功能 三、附录 1. logging.basicConfig介绍 2. 精确到毫秒&#xff0c;打印时间 方法一&#xff1a;使用datetime 方法二&#xff1a;使用time 一、Python元编程…