linux怎么查看本机内存大小
262
2022-10-23
Docker进阶-使用Dockerfile
Dockerfiel介绍
Dockerfile构建过程
DockerFile指令
FROM #基础镜像,一切从这里开始构建 MAINTAINER #镜像是谁写的,姓名+邮箱 RUN #镜像构建的时候需要运行的命令 ADD #步骤:Tomcat镜像,这个tomcat压缩包!添加内容 WORKDIR #镜像工作目录 VOLUME #挂载的目录 EXPOSE #暴露端口配置 CMD #指定这个容器启动的时候要运行的命令,只有最后一个会生效,可被替代 ["ls","-a"] ENTRYPOINT #指定这个容器启动的时候要运行的命令,可以追加命令 ["ls","-a"] ONBUILD #当构建一个被继承DockerFile 这个时候就会运行ONBUILD 的指令,出发指令 COPY #类似ADD,将我们的文件拷贝到镜像中 ENV #构建的时候设置环境变量
创建一个自己的centos
1.#编写一个Dockerfile的文件
[root@localhost dockerfile]# cat mydockerfile-centos
FROM centos
MAINTAINER xaingguo
实操搞一下:Tomcat镜像
FROM centos:7
MAINTAINER nature
3.构建镜像
[root@xiangguo tomcat]# docker build -t diytomcat . [root@xiangguo tomcat]# docker images
[root@xiangguo tomcat]# docker run -d -p 9090:8080 --name xgtomcat -v /home/nature/build/tomcat/test:/usr/local/apache-tomcat-9.0.22/webapps/test -v /home/nature/build/tomcat/tomcatlogs/:/usr/local/apache-tomcat-9.0.22/logs diytomcat
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
发布自己的镜像
DockerHub地址:<~]# docker login --help Usage: docker login [OPTIONS] [SERVER] Log in to a Docker registry. If no server is specified, the default is defined by the daemon. Options: -p, --password string Password --password-stdin Take the password from stdin -u, --username string Username
登陆成功后,提交镜像
[root@xiangguo ~]# docker login -u liuzhaoxuan Password: WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded [root@xiangguo ~]# docker push liuzhaoxuan/diytomcat:1.0 The push refers to repository [docker.io/liuzhaoxuan/diytomcat] An image does not exist locally with the tag: liuzhaoxuan/diytomcat
[root@xiangguo ~]# docker tag eb50604912df lzx/diytomcat:1.0 [root@xiangguo ~]# docker iomages docker: 'iomages' is not a docker command. See 'docker --help' [root@xiangguo ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE diytomcat latest eb50604912df 8 hours ago 727MB lzx/diytomcat 1.0 eb50604912df 8 hours ago 727MB mysql latest 5c62e459e087 8 weeks ago 556MB cmdtest latest dc266f7bb898 2 months ago 204MB nginx latest f0b8a9a54136 3 months ago 133MB tomcat latest c0e850d7b9bb 3 months ago 667MB hello-world latest d1165f221234 5 months ago 13.3kB centos 7 8652b9f0cb4c 9 months ago 204MB [root@xiangguo ~]# docker push lzx/diytomcat:1.0 The push refers to repository [docker.io/lzx/diytomcat] 962fe093e7b9: Preparing 168475953090: Preparing cc841424475a: Preparing d3b8ca1656d5: Preparing 0ac7206ca0c3: Preparing 174f56854903: Waiting denied: requested access to the resource is denied 但是会拒绝
[root@xiangguo ~]# docker tag eb50604912df liuzhaoxuan/lzxtomcat:1.0 [root@xiangguo ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE diytomcat latest eb50604912df 22 hours ago 727MB liuzhaoxuan/lzxtomcat 1.0 eb50604912df 22 hours ago 727MB mysql latest 5c62e459e087 8 weeks ago 556MB cmdtest latest dc266f7bb898 2 months ago 204MB nginx latest f0b8a9a54136 3 months ago 133MB tomcat latest c0e850d7b9bb 3 months ago 667MB hello-world latest d1165f221234 5 months ago 13.3kB centos 7 8652b9f0cb4c 9 months ago 204MB [root@xiangguo ~]# docker push liuzhaoxuan/lzxtomcat:1.0 The push refers to repository [docker.io/liuzhaoxuan/lzxtomcat] 962fe093e7b9: Pushed 168475953090: Pushing [===> ] 12.5MB/183.8MB cc841424475a: Pushing [====================> ] 6.31MB/15.49MB d3b8ca1656d5: Pushing [> ] 4.368MB/324MB 0ac7206ca0c3: Pushed 174f56854903: Pushing [==> ] 11.99MB/203.9MB 这样就正在上传。
小结
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~