# 生产的新镜像的base image, 也可以认为是面向对象编程中的基础类, alping:是个mini的linux 系统
FROM alpine:latest
# 没有特殊含义, 只是说明作者或维护人是谁
MAINTAINER laoliu
# 运行命令 以及多种命令组合
CMD echo 'hello docker'
这是第一个Dockerfile的内容:
FROM alpine:latest
MAINTAINER laoliu
CMD echo 'hello docker'
第一个Dockerfile的创建,验证, 测试运行流程:
[root@laoliu home]# mkdir docker1
[root@laoliu home]# cd docker1/
[root@laoliu docker1]# vim Dockerfile
# 此处将第一个Dockerfile的内容输入进去并保存退出
# 请注意build命令最后的点,表示当前目录下的所有文件
[root@laoliu docker1]# docker build -t hello_docker:v1 .
Sending build context to Docker daemon 2.048 kB
Step 1/3 : FROM alpine:latest
Trying to pull repository docker.io/library/alpine ...
latest: Pulling from docker.io/library/alpine
bdf0201b3a05: Pull complete
Digest: sha256:28ef97b8686a0b5399129e9b763d5b7e5ff03576aa5580d6f4182a49c5fe1913
Status: Downloaded newer image for docker.io/alpine:latest
---> cdf98d1859c1
Step 2/3 : MAINTAINER loaliu
---> Running in 2f4c8881f105
---> e586be09dba6
Removing intermediate container 2f4c8881f105
Step 3/3 : CMD echo "hello Docker"
---> Running in d6209286134c
---> 388e1bb2a5f7
Removing intermediate container d6209286134c
Successfully built 388e1bb2a5f7
[root@laoliu docker1]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello_docker v1 388e1bb2a5f7 2 minutes ago 5.53 MB
docker.io/nginx latest 27a188018e18 2 weeks ago 109 MB
docker.io/alpine latest cdf98d1859c1 3 weeks ago 5.53 MB
[root@laoliu docker1]# docker run hello_docker:v1
hello Docker
[root@laoliu docker1]#
内容如下: # 为注释
FROM ubuntu
MAINTAINER laoliu
# 加速连接
RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
# 更新apt包, 建议经常配置
RUN apt-get update
# 下载nginx
RUN apt-get install -y nginx
# 复制index.html文件到image中
COPY index.html /var/www/html
# 容器入口
ENTRYPOINT ["/usr/sbin/nginx", "-g", "daemon off;"]
# 暴露端口
EXPOSE 80
流程如下:
[root@laoliu home]# mkdir docker2
[root@laoliu home]# cd docker2/
[root@laoliu docker2]# vim Dockerfile
# 输出上面的第二个Dockerfile 文件内容
[root@laoliu docker2]# vim index.html
# 将下面三行写入index.html
#
#求工作...
#