vim Dockerfile

  1. FROM alpine:latest
  2. MAINTAINER brady
  3. CMD echo "hello world"

进行构建

docker build -t hello_docker .

  1. [root@localhost dnmp_test]# ls
  2. [root@localhost dnmp_test]# vim Dockerfile
  3. [root@localhost dnmp_test]# docker build -t hello_docker .
  4. Sending build context to Docker daemon 2.048 kB
  5. Step / : FROM alpine:latest
  6. Trying to pull repository docker.io/library/alpine ...
  7. latest: Pulling from docker.io/library/alpine
  8. 9d48c3bd43c5: Pull complete
  9. Digest: sha256:72c42ed48c3a2db31b7dafe17d275b634664a708d901ec9fd57b1529280f01fb
  10. Status: Downloaded newer image for docker.io/alpine:latest
  11. --->
  12. Step / : MAINTAINER brady
  13.  

  14. ---> Running in f1802f56a693
  15. ---> 00cdf7104f8b
  16. Removing intermediate container f1802f56a693
  17. Step / : CMD echo "hello world"
  18. ---> Running in e7b7a18d8c32
  19. ---> baa4664fe58d
  20. Removing intermediate container e7b7a18d8c32
  21. Successfully built baa4664fe58d
  22. [root@localhost dnmp_test]# docker images
  23. REPOSITORY TAG IMAGE ID CREATED SIZE
  24. hello_docker latest baa4664fe58d seconds ago 5.58 MB
  25. nginx-fun latest 6ea0e8bb024d minutes ago MB
  26. docker.io/nginx latest ab56bba91343 days ago MB
  27. docker.io/alpine latest weeks ago 5.58 MB
  28. [root@localhost dnmp_test]# docker run hello_docker
  29. hello world

推送到远程

  1. [root@localhost docker]# ls
  2. Dockerfile
  3. [root@localhost docker]# docker images
  4. REPOSITORY TAG IMAGE ID CREATED SIZE
  5. hello_docker latest c4ea4dd5f8f9 2 minutes ago 5.59MB
  6. alpine latest e7d92cdc71fe 5 weeks ago 5.59MB
  7. [root@localhost docker]# docker commit -a brady -m "hello docker" c4ea4dd5f8f9 yeves/hello_docker
  8. Error response from daemon: No such container: c4ea4dd5f8f9
  9. [root@localhost docker]# docker ps
  10. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  11. [root@localhost docker]# docker ps -a
  12. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  13. 59d586c17da1 hello_docker "/bin/sh -c 'echo \"h…" 2 minutes ago Exited (0) 2 minutes ago musing_shamir
  14. 9b8fe3409f62 hello_docker "/bin/sh -c 'echo \"h…" 2 minutes ago Exited (0) 2 minutes ago festive_nightingale
  15. [root@localhost docker]# docker commit -a brady -m "hello docker" 59d586c17da1 yeves/hello_docker
  16. sha256:315c59b50d02e0617d9249300f0f2f54fb929d4dcda124e71a07c87864455bcc
  17. [root@localhost docker]# docker images
  18. REPOSITORY TAG IMAGE ID CREATED SIZE
  19. yeves/hello_docker latest 315c59b50d02 6 seconds ago 5.59MB
  20. hello_docker latest c4ea4dd5f8f9 3 minutes ago 5.59MB
  21. alpine latest e7d92cdc71fe 5 weeks ago 5.59MB
  22. [root@localhost docker]# docker login
  23. Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
  24. Username: yeves
  25. Password:
  26. WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
  27. Configure a credential helper to remove this warning. See
  28. https://docs.docker.com/engine/reference/commandline/login/#credentials-store
  29.  
  30. Login Succeeded
  31. [root@localhost docker]# docker images
  32. REPOSITORY TAG IMAGE ID CREATED SIZE
  33. yeves/hello_docker latest 315c59b50d02 49 seconds ago 5.59MB
  34. hello_docker latest c4ea4dd5f8f9 4 minutes ago 5.59MB
  35. alpine latest e7d92cdc71fe 5 weeks ago 5.59MB
  36. [root@localhost docker]# docker tag 315c59b50d02 yeves/hellow_docker:v1.0
  37. [root@localhost docker]# docker images
  38. REPOSITORY TAG IMAGE ID CREATED SIZE
  39. yeves/hello_docker latest 315c59b50d02 About a minute ago 5.59MB
  40. yeves/hellow_docker v1.0 315c59b50d02 About a minute ago 5.59MB
  41. hello_docker latest c4ea4dd5f8f9 4 minutes ago 5.59MB
  42. alpine latest e7d92cdc71fe 5 weeks ago 5.59MB
  43. [root@localhost docker]# docker push yeves/hello_docker:v1.0
  44. The push refers to repository [docker.io/yeves/hello_docker]
  45. tag does not exist: yeves/hello_docker:v1.0
  46. [root@localhost docker]#

  

dockerfile创建镜像1的更多相关文章

  1. docker——Dockerfile创建镜像

    写在前面: 继续docker的学习,昨天用docker成功跑了tomcat,但是在centos中镜像跑的容器手动装jdk和tomcat,今天学习用Dockerfile创建镜像,并在上面搭建java环境 ...

  2. Dockerfile创建镜像

    Dockerfile是一个文本格式的配置文件,用户可以使用Dockerfile来快速创建自定义的镜像. Dockerfile由一行行命令语句组成,并且支持易#开头的注释行. 一般而言Dockerfil ...

  3. docker常用命令、镜像命令、容器命令、数据卷,使用dockerFile创建镜像,dockefile的语法规则。

    一.docker常用命令? 1. 常用帮助命令 1.1 docker的信息以及版本号 /* docker info 查看docker的信息 images2 docker本身就是一个镜像. docker ...

  4. 如何用Dockerfile创建镜像

    本文原创,原文地址为:http://www.cnblogs.com/fengzheng/p/5181222.html 创建镜像的目的 首先说DockerHub或其它一些镜像仓库已经提供了够多的镜像,有 ...

  5. docker学习笔记6:利用dockerfile创建镜像介绍(生成简单web服务器镜像)

    本文介绍如何利用dockerfile来创建镜像.下面介绍具体的操作过程: 一.创建构建环境 操作示例如下: xxx@ubuntu:~$ pwd /home/xxx xxx@ubuntu:~$ mkdi ...

  6. 使用Dockerfile创建镜像

    Dockerfile是一个文本格式的配置文件,用户可以使用Dockerfile来快速创建自定义的镜像. 一.基本结构 Dockerfile由一行行命令语句组成,并且支持以#开头的注释行. 一般而言,D ...

  7. [转]Docker基础-使用Dockerfile创建镜像

    本文转自:https://www.cnblogs.com/jie-fang/p/7927643.html 1.基本结构 Dockerfile由一行行命令语句组成,并支持以#开头的注释行.例如: # T ...

  8. Docker基础-使用Dockerfile创建镜像

    1.基本结构 Dockerfile由一行行命令语句组成,并支持以#开头的注释行.例如: # This dockerfile uses the ubuntu image # VERSION 2 - ED ...

  9. Docker学习笔记之通过 Dockerfile 创建镜像

    0x00 概述 由于 Docker 镜像的结构优势,使它的占用空间远小于普通的虚拟机镜像,而这就大幅减少了 Docker 镜像在网络或者其他介质中转移所花费的时间,进而提高了我们进行迁移部署的效率.不 ...

  10. docker Dockerfile 创建镜像

    Docker 组件 1. docker client : docker的客户端 2. docker server : docker daemon的主要组成部分,接受用户通过docker client发 ...

随机推荐

  1. Python高级笔记(八)with、上下文管理器

    1. 上下文管理器 __enter__()方法返回资源对象,__exit__()方法处理一些清除资源 如:系统资源:文件.数据库链接.Socket等这些资源执行完业务逻辑之后,必须要关闭资源 #!/u ...

  2. Spring cloud微服务安全实战-3-6API安全机制之数据校验

    校验:非空.唯一性等校验 密码的加密:密码加密来存储. 如何做https的访问 校验 一个层面是接口层面,另外一个层面是数据库层面. Springboot给我们提供了简单的封装 校验的包里面还有其他的 ...

  3. ABAP函数篇2 测试DATE_CONVERT_TO_FACTORYDATE

    DATE_CONVERT_TO_FACTORYDATE   根据日期返回工厂日历日期 函数功能说明: 标出工作日的计算方法 输入传输 CORRECT_OPTION = '+'如果指定的日期不是工作日, ...

  4. 18点睛Spring4.1-Meta Annotation

    18.1 Meta Annotation 元注解:顾名思义,就是注解的注解 当我们某几个注解要在多个地方重复使用的时候,写起来比较麻烦,定义一个元注解可以包含多个注解的含义,从而简化代码 下面我们用& ...

  5. [概率DP][消元法][CF24D]损坏的机器人

    Description 有一只坏了的机器人站在一个\(n\times m\)的网格里,初始位置在\((x,y)\).现在每个单位时间内它会随机选左右下三个方向走,如果它随机的方向会走出网格就不会往这个 ...

  6. JDBC(连接数据库的四个主要步骤)

    JDBC连接数据库 ?创建一个以JDBC连接数据库的程序,包含7个步骤: 1.加载JDBC驱动程序: 在连接数据库之前,首先要加载想要连接的数据库的驱动到JVM(Java虚拟机), 这通过java.l ...

  7. flask 密钥问题

    RuntimeError RuntimeError: The session is unavailable because no secret key was set. Set the secret_ ...

  8. C语言实现从左向右字幕滚动的效果

    #include <stdio.h> #include <string.h> #include <windows.h> int main() { char str[ ...

  9. Mac上Docker的安装

    安装 安装包安装 由于历史原因, 本人使用的是安装安装的方式, 这也是很多Windows用户的习惯. 下载地址: https://download.docker.com/mac/stable/Dock ...

  10. PHP LUHN算法验证银行卡

    <?php /* 16-19 位卡号校验位采用 Luhn 校验方法计算: 第一步:把信用卡号倒序(61789372994) 第二步:取出倒序后的奇数位置上的号码, 相加等到总和s1.(eg:s1 ...