黑猴子的家:制作Docker镜像

xiaoxiao2025-03-13  14

制作镜像

方式一:把容器提交成一个镜像

[root@node1 ~]# docker commit -m "new dir created" -a "My Docker" 787234sfs3234 newDocker **尖叫提示:参数****-m****表示提交信息,参数****-a****表示作者信息,****787234sfs3234****表示容器****ID,****生成镜像的名称,镜像****id** **一般只显示****12****位,但是提交时会显示全部****id**

方式二:根据镜像模板创建镜像

[root@node1 ~]# cat ubuntu-16.04.tar.gz | docker import - ubuntu:16.04

方式三:容器导入导出,加载镜像

[root@node1 ~]# docker export d5e > export_centos.tar [root@node1 ~]# docker import export_centos.tar test/centos:latest

方式四:Dockerfile

[root@node1 ~]# vim Dockerfile #This Dockerfile #Base images 在Dockerfile里面 "#" 是注释,第一行必须是FROM,基础镜像 FROM centos #Maintainer MAINTAINER Victor.LFJ [xxx@gmail.com](mailto:xxx@gmail.com) #Commands RUN rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm RUN yum -y install nginx && yum clean all RUN echo "daemon off;" >> /etc/nginx/nginx.conf ADD index.html /usr/share/nginx/html/index.html EXPOSE 80 CMD ["nginx"] [root@node1 ~]# docker build -t mynginx:v2 ./ **尖叫提示:****Dockerfile** **的这个****D** **必须是大写的**
转载请注明原文地址: https://www.6miu.com/read-5025772.html

最新回复(0)