docker镜像生成流程

  1. 制作Dockerfile
FROM alpine:3.6
RUN echo -e "http://mirrors.aliyun.com/alpine/v3.6/main\nhttp://mirrors.aliyun.com/alpine/v3.6/community" > /etc/apk/repositories
ENV LANG en_US.UTF-8
RUN apk add -U tzdata \
    && cp -r -f /usr/share/zoneinfo/Hongkong /etc/localtime
RUN apk add --no-cache ca-certificates python3 bash openssh git openssl-dev uwsgi uwsgi-python3
RUN apk add --no-cache --virtual .build-deps python3-dev gcc musl-dev libffi-dev make \
        && pip3 install --no-cache-dir --trusted-host mirrors.aliyun.com -i http://mirrors.aliyun.com/pypi/simple/ \
                pymysql==0.8.1 \
                Flask==1.0.2 \
                Flask-RESTful==0.3.6 \
                Flask-Script==2.0.6 \
                Flask-SQLAlchemy==2.3.2 \
                Flask-WTF==0.14.2 \
                SQLAlchemy==1.2.7 \
                simplejson==3.16.0 \
                six==1.11.0 \
                celery==4.2.1 \
                xlrd==1.1.0 \
                xlwt==1.3.0 \
                msgpack==0.5.0 \
                       && apk del .build-deps

RUN git clone https://github.com/Supervisor/supervisor.git \
        && cd supervisor \
        && python3 setup.py install \
        && cd .. \
        && rm -rf supervisor \
        && cd /etc/ \
        && echo_supervisord_conf > supervisord.conf \
        && echo '[include]' >> supervisord.conf \
        && echo 'files = /code/supervisor/*.ini' >> supervisord.conf \
        && supervisord -c /etc/supervisord.conf
  1. 进入Docker,进入Dockerfile所在的目录执行命令,最后的点代表当前目录
 docker build -t cms_api_image:v1 --rm=true .

alpine常用命令:
1.apk update 获取最新镜像源列表
2.apk search 查找所有可用软件包
3.apk add [软件名] 安装一个软件
4.apk info 列出已安装的软件包
5.apk del [软件名] 删除一个软件包
6.rc-update add [服务名] boot 系统启动时运行
例如:rc-update add docker boot 系统启动时运行docker服务
7.rc-service networking restart 重启系统的网络服务
8.reboot 重启系统
9.apk add –no-cache [软件名]
不使用本地镜像源,相当于先执行update,再执行add,该命令常用在Dockerfile中创建镜像.
例如: apk add –no-cache python3 安装python3

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章