• docker服务之制作镜像2


    制作aphine镜像

    aphine官方网址:https://www.alpinelinux.org/

    1、更换aphine的源

    $ docker run -it -p 8801:80 alpine:latest sh  #aphine没有bash环境,只能sh启动
    
    $ vi /etc/apk/repositories
    
    https://mirrors.aliyun.com/alpine/v3.10/community/
    https://mirrors.aliyun.com/alpine/v3.10/main/
    

    2、安装依赖软件

    apk update
    
    apk add iotop gcc libgcc libc-dev libcurl libc-utils libnfs make pcre pcre2 zip unzip net-tools pstree wget libevent libeve
    nt-dev iproute2
    
    

    3、编译安装nginx

    $ cd /opt
    $  wget http://nginx.org/download/nginx-1.16.1.tar.gz
    $ cd nginx-1.16.1/
    $ ./configure --prefix=/apps/nginx  && make && make install
    $ addgroup -g 2019 -S  nginx
    $   adduser -s /sbin/nologin -S -D -u 2019 -G nginx nginx
    $  vi conf/nginx.conf
    $  mkdir /data/nginx/html/linux37 -pv
    $ chown -R nginx.nginx /data/nginx /apps/nginx
    $ ln -sv /apps/nginx/sbin/nginx /usr/bin/
    

    aphine需要存放文件:

    root@docker-node1:/opt/dockerfile/system/aphine# ls
     bulid-command.sh  Dockerfile  linux37.tar.gz  nginx-1.16.1.tar.gz  nginx.conf  repositories
    

    构建Dockerfile

    
    FROM alpine
      
    maintainer pansn "www.pansn.cn"
    
    COPY repositories /etc/apk/repositories
    RUN apk update && apk add iotop gcc libgcc libc-dev libcurl libc-utils libnfs make pcre pcre2 zip unzip net-tools pstree wget libevent libevent-dev iproute2 pcre-dev zlib-dev
    
    #安装编译nginx
    ADD nginx-1.16.1.tar.gz /opt/
    RUN cd /opt/nginx-1.16.1 && ./configure --prefix=/apps/nginx && make && make install
    RUN addgroup -g 2019 -S  nginx && adduser -s /sbin/nologin -S -D -u 2019 -G nginx nginx &&  mkdir /data/nginx/html/linux37 -pv
    
    COPY nginx.conf /apps/nginx/conf/nginx.conf
    ADD  linux37.tar.gz /data/nginx/html
    RUN  chown -R nginx.nginx /data/nginx /apps/nginx && ln -sv /apps/nginx/sbin/nginx /usr/bin/
    
    
    EXPOSE 80 443
    
    CMD ["nginx"]
    
    

    验证:

    $  cat bulid-command.sh 
    #!/bin/bash
    docker build -t alpine-nginx:v1.16.1 .  #.代表在本目录执行Dockerfile
    
    $ bash bulid-command.sh 
    $ docker run -it -d -p 8804:80 alpine-nginx:v1.16.1
    

    制作Ubuntu镜像

    同理:将所需要 资源放在目录中

    root@docker-node1:/opt/dockerfile/system/ubuntu# ls
    bulid-command.sh  Dockerfile  linux37  linux37.tar.gz  nginx-1.16.1.tar.gz  nginx.conf  sources.list
    
    

    构建Dockerfile文件

    FROM ubuntu:18.04
      
    maintainer pansn "www.pansn.cn"
    
    COPY sources.list /etc/apt/sources.list
    
    RUN apt update &&  apt install -y make iproute2 ntpdate tcpdump telnet traceroute  lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ntpdate tcpdump telnet traceroute gcc openssh-server lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ntpdate tcpdump telnet traceroute iotop unzip zip
    
    ADD nginx-1.16.1.tar.gz /usr/local/src
    RUN cd /usr/local/src/nginx-1.16.1 && ./configure --prefix=/apps/nginx && make && make install && ln -sv /apps/nginx/sbin/nginx /usr/bin && mkdir /data/nginx/html/ -pv
    
    ADD nginx.conf /apps/nginx/conf/nginx.conf
    ADD linux37.tar.gz /data/nginx/html
    
    RUN groupadd -g 2019 nginx && useradd -g nginx -s /usr/sbin/nologin -u 2019 nginx
    RUN chown nginx.nginx /apps/nginx /data/nginx -R
    
    EXPOSE 80 443
    
    CMD ["nginx"]                           
    
    

    验证启动:

     docker run -it -d -p 8806:80 ubuntu-nginx:v1.18.04
    

  • 相关阅读:
    疯狂秀才基本权限管理框架2012新版
    保存网站或系统的全局配置使用JSON格式保存到文件更轻便!
    ASP.NET MVC3 学习笔记(一)MVC模式简介
    疯狂秀才基本权限管理框架2012(国庆版)
    使用Knockout 绑定简单 json 对象
    jquery.Validate API 中文CHM版 疯狂秀才整理
    EasyUI 中 MenuButton 的使用方法
    Javascript Object的使用方法
    Javascript 定义二维数组的方法
    HTML5 Web存储的localStorage和sessionStorage的使用方法【图文说明】
  • 原文地址:https://www.cnblogs.com/pansn/p/11528145.html
Copyright © 2020-2023  润新知