dockerfile镜像制作

dockerfile镜像制作

1.创建镜像目录

mkdir imgl

2.创建Dockerfile

cd imgl
vim Dockerfile

进入编辑模式

# Descriprion: test image
FROM busybox:latest
MAINTAINER "myt2000 <myt2000@126.com>"
# LABEL maintainer= "myt2000 <myt2000@126.com>"
COPY index.html /data/web/html/
COPY yum.repos.d /etc/yum.repos.d/

创建index.html 并写入内容
将/etc/yum.repos.d 拷贝如imgl目录下

3.创建镜像

[root@localhost imgl]# docker build -t tinyhttpd:v0.1-1 ./
Sending build context to Docker daemon  22.53kB
Step 1/4 : FROM busybox:latest
 ---> e4db68de4ff2
Step 2/4 : MAINTAINER "myt2000 <myt2000@126.com>"
 ---> Using cache
 ---> 16c2f515051b
Step 3/4 : COPY index.html /data/web/html/
 ---> Using cache
 ---> 80277675b1c3
Step 4/4 : COPY yum.repos.d /etc/yum.repos.d/
 ---> c58ae4523e4b
Successfully built c58ae4523e4b
Successfully tagged tinyhttpd:v0.1-1

查看镜像

[root@localhost imgl]# docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
tinyhttpd           v0.1-1              c58ae4523e4b        About a minute ago   1.24MB

4.启动镜像

[root@localhost imgl]# docker run --name tinyweb1 --rm tinyhttpd:v0.1-1 cat /data/web/html/index.html
<h1>busybox .hi</h1>
[root@localhost imgl]# docker run --name tinyweb1 --rm tinyhttpd:v0.1-1 ls /etc/yum.repos.d/
CentOS-Base.repo
CentOS-CR.repo
CentOS-Debuginfo.repo
CentOS-Media.repo
CentOS-Sources.repo
CentOS-Vault.repo
CentOS-fasttrack.repo
docker-ce.repo


5.ADD命令

Dockerfile

# Descriprion: test image
FROM busybox:latest
MAINTAINER "myt2000 <myt2000@126.com>"
# LABEL maintainer= "myt2000 <myt2000@126.com>"
COPY index.html /data/web/html/
COPY yum.repos.d /etc/yum.repos.d/
ADD http://nginx.org/download/nginx-1.17.1.tar.gz /usr/local/src/

[root@localhost imgl]# docker build -t tinyhttpd:v0.1-3 ./
Sending build context to Docker daemon  22.53kB
Step 1/5 : FROM busybox:latest
 ---> e4db68de4ff2
Step 2/5 : MAINTAINER "myt2000 <myt2000@126.com>"
 ---> Using cache
 ---> 16c2f515051b
Step 3/5 : COPY index.html /data/web/html/
 ---> Using cache
 ---> 80277675b1c3
Step 4/5 : COPY yum.repos.d /etc/yum.repos.d/
 ---> Using cache
 ---> c58ae4523e4b
Step 5/5 : ADD http://nginx.org/download/nginx-1.17.1.tar.gz /usr/local/src/
Downloading  1.033MB/1.033MB
 ---> 1c1cc18ce353
Successfully built 1c1cc18ce353
Successfully tagged tinyhttpd:v0.1-3

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值