制作你的第一个dockerfile文件

From this lesson you will
从这里你将学到
1,Make a Dockerfile
制作一个Dockerfile
2,Build a Docker Image and run
构建镜像并且运行
3,Learn about 3 Basic Dockerfile  commands
学会三个Dockerfile命令
4,Some tips
一些提示

环境:Centos7,Docker CE

 

到开terminal命令行

1,

sudo vi Dockerfile

 

输入如下内容退出保存:

FROM ubuntu
MAINTAINER Liping<tlping@163.com>
CMD echo 'This is the first docker file'

 

2,

sudo docker build -t myfirstimage .

 

 


3,

sudo docker run myfirstimage

 


Dockerfile commands


FROM : Specify your docker image will inherit from where

指定镜像继承自哪个docker镜像

MAINTAINER: the auther 's email address

镜像的维护者email

CMD:  When start the container, CMD allows you to execute some shell commands for initialization.

当启动容器时,可以使用CMD来执行shell命令,进行一些初始化。


Some tips:

Normally you can name your file as 'Dockerfile' , you can also use other names ,

but in that case you will need to use a absolute path(with dockerfile name) to build your docker image.

通常需要将你的文件命名为'Dockerfile',也可以用其他名字,

但如果使用其他名字,在编译路径中需要使用路径(绝对或相对路径带dockerfile名)编译镜像;

 

posted on 2019-09-01 11:53  立平  阅读(1102)  评论(0)    收藏  举报

导航