在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
Usage: docker build [OPTIONS] PATH | URL | - [flags] Options: -t, --tag list # 镜像名称 -f, --file string # 指定Dockerfile文件位置
前提:已经准备好了 如下文件(谁需要相关文件的,最下面有我微信,欢迎添加获取):
#现把文件从windows上传输到linux,发现xshell没有安装 rz命令,那么就不支持把windows文件拖进linux机器 [root@192 ~]# rz -bash: rz: 未找到命令 #安装rz工具 [root@192 yum install lrzsz 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn base | 3.6 kB 00:00:00 docker-ce-stable | 3.5 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 正在解决依赖关系 --> 正在检查事务 ---> 软件包 lrzsz.x86_64.0.0.12.20-36.el7 将被 安装 --> 解决依赖关系完成 依赖关系解决 ================================================================================================================= Package 架构 版本 源 大小 ================================================================================================================= 正在安装: lrzsz x86_64 0.12.20-36.el7 base 78 k 事务概要 ================================================================================================================= 安装 1 软件包 总下载量:78 k 安装大小:181 k Is this ok [y/d/N]: y Downloading packages: lrzsz-0.12.20-36.el7.x86_64.rpm | 78 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安装 : lrzsz-0.12.20-36.el7.x86_64 1/1 验证中 : lrzsz-0.12.20-36.el7.x86_64 1/1 已安装: lrzsz.x86_64 0:0.12.20-36.el7 完毕! #将windows文件拖进xshell, 会出现图形界面,显示传输进度 [root@192 ~]# rz -E rz waiting to receive. #确认 dockerfile_.zip传输进了linux宿主机 [root@192 ~]# ls anaconda-ks.cfg dockerfile_.zip nginx.tar # 发现unzip工具没有安装 [root@192 ~]# unzip -bash: unzip: 未找到命令 #安装unzip工具 [root@192 ~]# yum install unzip -y 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn 正在解决依赖关系 --> 正在检查事务 ---> 软件包 unzip.x86_64.0.6.0-19.el7 将被 安装 --> 解决依赖关系完成 依赖关系解决 ================================================================================================================= Package 架构 版本 源 大小 ================================================================================================================= 正在安装: unzip x86_64 6.0-19.el7 base 170 k 事务概要 ================================================================================================================= 安装 1 软件包 总下载量:170 k 安装大小:365 k Downloading packages: unzip-6.0-19.el7.x86_64.rpm | 170 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安装 : unzip-6.0-19.el7.x86_64 1/1 验证中 : unzip-6.0-19.el7.x86_64 1/1 已安装: unzip.x86_64 0:6.0-19.el7 完毕! 解压 dockerfile_.zip 文件 [root@192 ~]# unzip dockerfile_.zip Archive: dockerfile_.zip inflating: Dockerfile-nginx inflating: Dockerfile-php inflating: Dockerfile-tomcat inflating: nginx.conf inflating: php-fpm.conf inflating: php.ini [root@192 ~]# ls -l 总用量 110492 -rw-------. 1 root root 1282 3月 11 16:29 anaconda-ks.cfg -rw-r--r-- 1 root root 833 11月 25 20:29 Dockerfile-nginx -rw-r--r-- 1 root root 1331 11月 3 11:06 Dockerfile-php -rw-r--r-- 1 root root 862 11月 25 20:30 Dockerfile-tomcat -rw-r--r-- 1 root root 33157 11月 25 20:30 dockerfile_.zip -rw-r--r-- 1 root root 1137 10月 29 03:02 nginx.conf -rw-r--r--. 1 root root 112984576 3月 11 17:37 nginx.tar -rw-r--r-- 1 root root 23104 10月 29 02:57 php-fpm.conf -rw-r--r-- 1 root root 73696 11月 3 12:55 php.ini [root@192 ~]# vi Dockerfile-nginx [root@192 ~]# docker build -t nginx:v1 -f Dockerfile-nginx . Sending build context to Docker daemon 113.1MB Step 1/9 : FROM centos:7 ---> 1e1148e4cc2c Step 2/9 : MAINTAINER www.ctnrs.com ---> Running in bf77ab5a1997 Removing intermediate container bf77ab5a1997 ---> 518178772205 Step 3/9 : RUN yum install -y gcc gcc-c++ make openssl-devel pcre-devel gd-devel iproute net-tools telnet wget curl && yum clean all && rm -rf /var/cache/yum/*
作者: 梅梅~ 出处: https://www.cnblogs.com/keeptesting 关于作者:专注软件测试,测试运维相关工作,请多多赐教! 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出, 原文链接 欢迎沟通交流加微信联系。 微信:yangguangkg20140901 暗号:博客园. |
2022-08-15
2022-11-06
2022-08-15
2022-07-18
2022-08-17
请发表评论