Ubuntu18.04镜像制作

Dockfile

Dockfile

#!/bin/bash
FROM ubuntu:18.04
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo Asia/Shanghai > /etc/timezone
ENV LANG C.UTF-8

EXPOSE  20998
COPY .  /data/code

RUN  sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list && \
     apt-get clean && \
     apt-get update --fix-missing && \
     apt-get install -y libmysqlclient-dev tzdata  \
                        python3 python3-dev python3-pip redis-server vim net-tools \
    && apt-get clean \
    && apt-get autoclean \
	&& ln -s /usr/bin/pip3 /usr/bin/pip && ln -s /usr/bin/python3 /usr/bin/python \

	&& pip3 install -r /data/code/requirements.txt -i https://mirrors.aliyun.com/pypi/simple  \
	&& rm -rf /var/lib/apt/lists/*
# --- install requirements ---
WORKDIR /data/code
RUN chmod +x /data/code/start_script.sh
# --- running service ---
CMD  /bin/bash  start_script.sh

python3.7镜像制作

#!/bin/bash
FROM python:3.7-stretch
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo Asia/Shanghai > /etc/timezone
EXPOSE  8899
COPY .  /data/code

# --- install requirements ---

RUN pip install --no-cache-dir --user --default-timeout=100 -i https://mirrors.aliyun.com/pypi/simple/ -r  /data/code/requirements.txt

# --- running service ---
WORKDIR /data/code
CMD ["python", "main.py"]

 start_script.sh

#!/bin/bash
nohup  redis-server&

PYTHONIOENCODING=utf-8  python3 main.py


镜像容器制作

docker build -t server_api:v2 .
docker run -itd -p 18899:8899  -v   /home/irecog/server_api:/data/code    --name      server_api    server_api:v2

Docker官网: https://docs.docker.com/
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值