zoukankan      html  css  js  c++  java
  • 使用空镜像scratch构建镜像

    • 1.使用空镜像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

    
    
    • 2.创建Dockerfile文件

    新建一个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;"]
    • 3.执行命令,构建镜像 

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

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

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

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

  • 相关阅读:
    Vue 下拉刷新及无限加载组件
    VUE常用问题hack修改
    CSS滤镜让图片模糊(毛玻璃效果)实例页面
    滑动删除
    拖动选择单元格并合并方法
    Windows7上开启ftp服务器功能
    js 向上滚屏
    理解Clip Path
    图标制作
    transition实现图片轮播
  • 原文地址:https://www.cnblogs.com/momoyan/p/13966978.html
Copyright © 2011-2022 走看看