美文网首页
docker笔记(三)

docker笔记(三)

作者: maxZhang | 来源:发表于2018-06-26 16:45 被阅读4次

Dockerfile相关操作

//创建目录dockerfile2
mkdir dockerfile2
//进入目录
cd dockerfile2
//创建文件Dockerfile
touch Dockerfile
//编辑文件Dockerfile
vim Dockerfile 

编辑的文件如下

//从ubuntu镜像拉取
FROM ubuntu
//作者
MAINTAINER max
//更改站点,提高速度
RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
//更新软件源中的所有软件列表
RUN apt-get update
//在ubuntu上安装nginx, -y表示安装过程中无需提示
RUN apt-get install -y nginx
//拷贝文件index.html到容器里面去
COPY index.html /var/www/html
//提供入点, 数组用空格隔开展开执行 -g表示nginx在前端执行
ENTRYPOINT ["/usr/sbin/nginx", "-g", "daemon off;"]
//表示暴露端口为80
EXPOSE 80

新建index.html

touch index.html

//编辑html文件如下

<html>
hello ubuntu nginx
</html>

构建

//后面.作为 当前目录上下文
docker build -t ubuntu_nginx .

相关文章

网友评论

      本文标题:docker笔记(三)

      本文链接:https://www.haomeiwen.com/subject/blrmyftx.html