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

news2024/11/18 15:33:56

目录

基于已有容器创建镜像

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

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【电网技术复现】考虑实时市场联动的电力零售商鲁棒定价策略(Matlab代码实现)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…

动画制作选择Blender还是Maya

Blender和Maya是两种最广泛使用的 3D 建模和动画应用程序。许多经验丰富的用户表示&#xff0c;Blender 在雕刻工具方面远远领先于 Maya&#xff0c;并且在 3D 建模方面达到了相同的质量水平。对于刚接触动画行业的人来说&#xff0c;您可能会问“我应该使用 Blender 还是 Maya…

二、数据结构10:堆 模板题+算法模板(堆排序,模拟堆)

文章目录 算法模板堆题目代码模板堆的原理down操作理解&#xff1a;up操作理解建堆操作关于heap_swap中存的映射数组理解&#xff08;模拟堆题目中用到&#xff09; 模板题堆排序原题链接题目思路题解 模拟堆原题链接题目思路题解 算法模板 堆题目代码模板 // h[N]存储堆中的…

【啥都生】分类项目中的模型搭建代码解析

def build_model(cfg):if isinstance(cfg, list):modules [eval(cfg_.pop("type"))(**cfg_) for cfg_ in cfg]return Sequential(*modules)else:return eval(cfg.pop("type"))(**cfg)b站up啥都生维护的分类项目 这段代码的功能是完成模型搭建&#xff0c;…

Cesium态势标绘专题-文本标注(标绘+编辑)

标绘专题介绍:态势标绘专题介绍_总要学点什么的博客-CSDN博客 入口文件:Cesium态势标绘专题-入口_总要学点什么的博客-CSDN博客 辅助文件:Cesium态势标绘专题-辅助文件_总要学点什么的博客-CSDN博客 本专题没有废话,只有代码,代码中涉及到的引入文件方法,从上面三个链…

Vue模版语法

先看以下例题是回顾vue的用法 <body><div id"box">{{myname}} - {{myage}}</div><script>var vm new Vue({el:"#box",data:{myname:"lyx",myage:26}})</script></body> 运行结果如下&#xff1a;vue对象被…

什么是熵?

熵&#xff08;Entropy&#xff09;是一个重要的概念&#xff0c;最初出现在热力学领域&#xff0c;用于描述系统的混乱程度或不确定性。熵也被广泛应用于信息理论、统计学和计算机科学等领域。通常来讲&#xff0c;熵&#xff0c;是对混乱程度、不确定程度的度量。熵越大&…

【测试学习三】软件测试的生命周期 BUG的相关知识

目录 一、软件测试的生命周期&#xff08;重要&#xff09; &#x1f351;1、软件的生命周期&#xff1f; &#x1f351;2、软件测试的生命周期&#xff1f; 二、关于BUG &#x1f351;1、如何描述与定义一个BUG&#xff1f;&#xff08;了解&#xff09; &#x1f351;2…

分时电价调整后上海储能项目投资回收期分析-安科瑞黄安南

2022年12月16日&#xff0c;上海市发改委发布《关于进一步完善我市分时电价机制有关事项的通知》(沪发改价管〔2022〕50号)。通知明确上海分时电价机制&#xff0c;一般工商业及其他两部制、大工业两部制用电夏季&#xff08;7、8、9月&#xff09;和冬季&#xff08;1、12月&a…

Tomcat安装与管理

文章目录 Tomcat安装及管理Tomcat gz包安装&#xff1a;JDK安装&#xff1a;Tomcat安装&#xff1a;修改配置文件&#xff08;如下&#xff09;&#xff1a;服务启动配置&#xff1a; Tomcat-管理(部署jpress)&#xff1a;修改允许访问的主机修改允许管理APP的主机进入管理&…

实用干货!一文读懂Salesforce中6种数据关系类型!

Salesforce中对象之间的数据关系可能是一个棘手的话题。对于创建自定义对象的业务场景&#xff0c;需要决定使用哪些关系类型来扩展Salesforce数据模型。 01 查找关系 查找关系&#xff08;Lookup Relationships&#xff09;是一种松散耦合&#xff08;loosely coupled&…

【SQL】-【计算两个varchar类型的timestamp的毫秒差】

背景 TRANSTAMP3、TRANSTAMP2在Oracle数据库中的类型为varchar&#xff0c;但实际保存的值是时间戳timestamp类型&#xff0c;现在要计算二者的毫秒差 Oracle或MySQL extract(second from (to_timestamp(TRANSTAMP3,yyyy-mm-dd hh24:mi:ss.ff) - to_timestamp(TRANSTAMP2,yyy…

盘点那些不想骑车的原因和借口。

在自行车骑行的热潮中&#xff0c;我们都会找到各种千奇百怪的借口来解释我们为什么不想骑。本文将结合当前热点话题和趋势&#xff0c;从心理学、文化等多个角度&#xff0c;深入探讨这些借口背后的原因。 首先&#xff0c;我们不能忽视的是&#xff0c;骑行是一项需要耐力和毅…

web集群学习

目录 简述静态网页和动态网页的区别 Webl.0 和 Web2.0 的区别 安装tomcat8&#xff0c;配置服务启动脚本&#xff0c;部署jpress应用 1、安装jdk文件&#xff1a; 2、下载tomcat的二进制包&#xff1a; 3、创建用户组和用户 创建Tomcat的登录服务脚本 此处创建的登录服务…

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

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

19-2.vuex

目录 1 安装 2 挂载 2.1 vue2写法 2.2 vue3写法 3 state 3.1 声明数据 3.2 使用数据 3.3 处理数据 4 mutations 4.1 基本使用 4.2 传递参数 4.3 mutations中不能写异步的代码 5 actions 5.1 基本使用 5.2 传递参数 6 getters Vuex是做全局数据…

CAS原理解析

CAS是一种乐观锁机制&#xff0c;一种比较并交换的过程和理念&#xff0c;用来解决线程安全问题&#xff0c;具体来讲就是对共享变量值的安全更新机制。能够保证原子、可见、一致性。这种交换过程是在Unsafe类中实现。 从一段简单的代码开始来对源码做分析 public static void…

坚鹏:常德市银行业协会BLM银行数字化转型战略培训圆满结束

常德市银行业协会BLM银行数字化转型战略培训圆满结束 在数字化转型背景下&#xff0c;常德市银行业协会为了落实监管政策《关于银行业保险业数字化转型的指导意见》&#xff0c;充分认识到学习银行银行数字化转型战略的价值和重要性&#xff0c;特别举办《2023年数字化转型战略…

06 Ubuntu22.04上的miniconda3安装、深度学习常用环境配置

下载脚本 我依然是在清华镜像当中寻找的脚本。这里找脚本真的十分方便&#xff0c;我十分推荐。 wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh 下载十分快速&#xff0c;10秒解决问题 运行miniconda3安装脚本 赋予执…

邀请媒体现场报道,有哪些作用?

传媒如春雨&#xff0c;润物细无声&#xff0c;大家好&#xff0c;我是51媒体网胡老师。 邀请媒体现场报道活动具有多种重要作用和意义&#xff0c;可以为你的活动带来广泛的曝光和正面影响。以下是一些邀请媒体现场报道的作用和意义&#xff1a; 1. 增加活动曝光度&#xff…