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