基于httpd镜像演示Dockerfile所有的指令:

第一步:创建Dockerfile工作目录

[root@localhost harbor]# mkdir /test
[root@localhost harbor]# cd /test/
[root@localhost test]# echo 11111 > 1.txt
[root@localhost test]# ls
1.txt
[root@localhost test]# vim Dockerfile
FROM httpd:latest
LABEL author=wuxun
ENV dir=/usr/local/apache2/htdocs
WORKDIR $dir
COPY 1.txt ./
RUN touch {1..3}.txt
ADD https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/adwaita-qt-common-1.0-1.el7.x86_64.rpm ./
EXPOSE 80 3306
VOLUME $dir
CMD ["httpd-foreground"] 

第二步:基于dockerfile创建镜像

[root@localhost test]# docker build -t httpd:test1
"docker build" requires exactly 1 argument.
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
[root@localhost test]# docker build -t httpd:test1 ./
Sending build context to Docker daemon 3.072kB
Step 1/10 : FROM httpd:latest
---> fb2f3851a971
...
Successfully built 8b0d23d4e733
Successfully tagged httpd:test1
[root@localhost test]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd test1 8b0d23d4e733 3 minutes ago 178MB

第三步:基于新创建的镜像启动容器

[root@localhost test]# docker run -d httpd:test1
5b6975fd8ad966bd8359ebe0538bd22cb0c9f43d2d6d98c64e806bef93f32e88
[root@localhost test]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5b6975fd8ad9 httpd:test1 "httpd-foreground" 18 seconds ago Up 17 seconds 80/tcp, 3306/tcp jolly_gagarin

第四步:验证  

[root@localhost test]# docker exec -it 5b6975fd8ad9 bash
root@5b6975fd8ad9:/usr/local/apache2/htdocs# ls
1.txt adwaita-qt-common-1.0-1.el7.x86_64.rpm index.html {1..3}.txt
root@5b6975fd8ad9:/usr/local/apache2/htdocs# exit
exit
[root@localhost test]# docker image ls |grep httpd
httpd test1 8b0d23d4e733 31 minutes ago 178MB
192.168.59.200/test/httpd v1 fb2f3851a971 18 months ago 178MB
httpd latest fb2f3851a971 18 months ago 178MB
[root@localhost test]# docker ps | grep httpd
5b6975fd8ad9 httpd:test1 "httpd-foreground" 26 minutes ago Up 26 minutes 80/tcp, 3306/tcp jolly_gagarin

  

最新文章

  1. 基于SAP的中国式数据分析浅谈
  2. 二刷Cracking the Coding Interview(CC150第五版)
  3. Android M Permission 运行时权限 学习笔记
  4. linux设备驱动概述,王明学learn
  5. C#获取当前日期时间(转)
  6. zf2-tutorial调通,坑爹的init_autoloader.php
  7. HW6.23
  8. 学做酷炫有爱的免费网页,学习 Github Page 教你分分钟搭建自己的博客
  9. 新版ADT出现appcompat_v7的问题
  10. Android 信鸽推送通知栏不显示推送的通知
  11. 使用简单的 5 个步骤设置 Web 服务器集群
  12. 【Oracle】物理体系结构
  13. Keras官方中文文档:序贯模型API
  14. Android控制软键盘的弹出和隐藏
  15. MongoDB_简介_安装_基本使用_js_mongoose 操作 MongoDB 编程
  16. ZigZag Conversion 之字形转换字符串
  17. ArcGIS for qml -测距
  18. Yolov3参数解释以及答疑
  19. poj2456 Aggressive cows(二分查找)
  20. js中Math.round、parseInt、Math.floor和Math.ceil小数取整小结【转】

热门文章

  1. MyEclipse注册代码
  2. 使用TryGetComponent取代GetComponent以避免Editor中的内存分配
  3. java和JavaScript的注释区别
  4. unittest生成测试报告
  5. vue-cli 中stylus写样式莫名报错?
  6. shark恒破解笔记3-EAX决定胜负
  7. [JZOJ5773]【NOIP2008模拟】简单数学题
  8. 冰释前嫌——转入Android Studio与连接手机无法识别问题
  9. Ceph Paxos相关代码解析
  10. LeetCode初级算法--动态规划01:爬楼梯