Docker中遇到的问题

  1. Dockerfile中的COPY用法
    答:copy中的源路径直能是相对路径
  2. Dockerfile中什么时候用pip,什么时候用pip3
    答:python3+的模块包包需要pip3来进行安装
    docker commit 遇到的小坑坑 - 简书 (jianshu.com)
    注意:docker run 镜像1 命令1 ,这个命令会代替镜像1的初始CMD命令0,在重新commit的时候CMD的命令为0;
  3. Dockerfile中的CMD命令,仅执行最后一个命令;
    (221条消息) Dockerfile CMD 命令详解_xyz的博客-优快云博客_dockerfile cmd
  4. 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" ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值