Dockerfile相關(guān)操作
//創(chuàng)建目錄dockerfile2
mkdir dockerfile2
//進(jìn)入目錄
cd dockerfile2
//創(chuàng)建文件Dockerfile
touch Dockerfile
//編輯文件Dockerfile
vim Dockerfile
編輯的文件如下
//從ubuntu鏡像拉取
FROM ubuntu
//作者
MAINTAINER max
//更改站點(diǎn)全蝶,提高速度
RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
//更新軟件源中的所有軟件列表
RUN apt-get update
//在ubuntu上安裝nginx, -y表示安裝過(guò)程中無(wú)需提示
RUN apt-get install -y nginx
//拷貝文件index.html到容器里面去
COPY index.html /var/www/html
//提供入點(diǎn)薪贫, 數(shù)組用空格隔開(kāi)展開(kāi)執(zhí)行 -g表示nginx在前端執(zhí)行
ENTRYPOINT ["/usr/sbin/nginx", "-g", "daemon off;"]
//表示暴露端口為80
EXPOSE 80
新建index.html
touch index.html
//編輯html文件如下
<html>
hello ubuntu nginx
</html>
構(gòu)建
//后面.作為 當(dāng)前目錄上下文
docker build -t ubuntu_nginx .