- 制作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
- 進(jìn)入Docker,進(jìn)入Dockerfile所在的目錄執(zhí)行命令,最后的點(diǎn)代表當(dāng)前目錄
docker build -t cms_api_image:v1 --rm=true .
- 基于鏡像新建容器吧并進(jìn)入交互終端
docker run -it cms_api_imge:v1 /bin/bash
alpine常用命令:
1.apk update 獲取最新鏡像源列表
2.apk search 查找所有可用軟件包
3.apk add [軟件名] 安裝一個(gè)軟件
4.apk info 列出已安裝的軟件包
5.apk del [軟件名] 刪除一個(gè)軟件包
6.rc-update add [服務(wù)名] boot 系統(tǒng)啟動(dòng)時(shí)運(yùn)行
例如:rc-update add docker boot 系統(tǒng)啟動(dòng)時(shí)運(yùn)行docker服務(wù)
7.rc-service networking restart 重啟系統(tǒng)的網(wǎng)絡(luò)服務(wù)
8.reboot 重啟系統(tǒng)
9.apk add –no-cache [軟件名]
不使用本地鏡像源,相當(dāng)于先執(zhí)行update,再執(zhí)行add,該命令常用在Dockerfile中創(chuàng)建鏡像.
例如: apk add –no-cache python3 安裝python3
docker常用命令: