使用空镜像scratch构建镜像

一.使用空镜像scratch构建镜像
操作步骤如下:
1.获取空镜像scratch #必须优先安装docker
docker search scratch
2.新建一个文件夹,用wget下载rootfs.tar.xz压缩包和nginx配置
wget -O rootfs.tar.xz https://github.com/debuerreotype/docker-debian-artifacts/raw/b024a792c752a5c6ccc422152ab0fd7197ae8860/jessie/rootfs.tar.xz
wget -O nginx.conf https://github.diablo.corp/raw/slvi/docker-k8s-training/master/docker/res/nginx.conf



新建一个dockerfile文件,将下列内容粘贴进去:

#引入一个空镜像
FROM scratch # set the environment to honour SAP's proxy servers ENV http_proxy http://sap.corp:8080 ENV https_proxy http://sap.corp:8080 ENV no_proxy .sap.corp # give yourself some credit LABEL maintainer="Jerry Wang" # add and unpack an archive that contains a Debian root filesystem ADD rootfs.tar.xz / # use the apt-get package manager to install nginx and wget RUN apt-get update && \ apt-get -y install nginx wget # use wget to download a custom website into the image RUN wget --no-check-certificate -O /usr/share/nginx/html/cheers.jpg https://github.diablo.corp/raw/slvi/docker-k8s-training/master/docker/res/cheers.jpg && \ wget --no-check-certificate -O /usr/share/nginx/html/index.html https://github.diablo.corp/raw/slvi/docker-k8s-training/master/docker/res/cheers.html # copy the custom nginx configuration into the image COPY nginx.conf /etc/nginx/nginx.conf # link nginx log files to Docker log collection facility RUN ln -sf /dev/stdout /var/log/nginx/access.log && \ ln -sf /dev/stderr /var/log/nginx/error.log # expose port 80 - the standard port for webservers EXPOSE 80 # and make sure that nginx runs when a container is created CMD ["nginx", "-g", "daemon off;"]

 执行命令进行镜像的构建:

 docker build -t nginx-from-scratch1.0 .

运行docker镜像,启动服务
 docker run -d -p 1083:80 nginx-from-scratch:1.0 
使用空镜像scratch构建镜像

 

浏览器访问:http://localhost:1083

 

------------恢复内容结束------------

上一篇:使用VBA从工作表中读图片,以及给工作表中写文件


下一篇:来写Makefile吧