- Dockerfile中的COPY用法
答:copy中的源路径直能是相对路径 - Dockerfile中什么时候用pip,什么时候用pip3
答:python3+的模块包包需要pip3来进行安装
docker commit 遇到的小坑坑 - 简书 (jianshu.com)
注意:docker run 镜像1 命令1 ,这个命令会代替镜像1的初始CMD命令0,在重新commit的时候CMD的命令为0; - Dockerfile中的CMD命令,仅执行最后一个命令;
(221条消息) Dockerfile CMD 命令详解_xyz的博客-优快云博客_dockerfile cmd - Dockerfile模板
注意:Dockerfile中每一条指令都创建镜像的一层,所以为了避免镜像过于复杂,占得内存过大,一般尽量减少层多行命令用&写一起。(同样的命令,分行写将会消耗更长的时间)
paddle 从git上拉包到文件夹里
FROM registry.baidubce.com/paddlepaddle/paddle:2.2.2
LABEL maintainer="paddlesl@baidu.com"
RUN apt-get update
RUN apt-get -y install libsndfile-dev
RUN apt-get clean
RUN git clone -b r1.2.0 --depth 1 https://github.com/PaddlePaddle/PaddleSpeech.git /home/PaddleSpeech
RUN pip3 uninstall mccabe -y ; exit 0;
RUN pip3 install multiprocess==0.70.12 importlib-metadata==4.2.0 dill==0.3.4 python-multipart -i https://mirror.baidu.com/pypi/simple
RUN pip3 install fastapi
COPY ./main.py requirements.txt /home/PaddleSpeech/
WORKDIR /home/PaddleSpeech/
RUN python setup.py bdist_wheel
RUN pip install dist/*.whl -i https://pypi.tuna.tsinghua.edu.cn/simple
CMD ["python","/home/PaddleSpeech/main.py"]
平常比赛docker模板
FROM python:3.7
WORKDIR /code
# 将源路径下的文件都复制到/code目录下
COPY ./ .
RUN pip3 config set global.index-url http://mirrors.myhuaweicloud.com/pypi/web/simple \
&& pip3 config set install.trusted-host mirrors.myhuaweicloud.com
RUN pip3 install -r requirements.txt -i https://mirror.baidu.com/pypi/simple
CMD [ "bash" ]