dockerfile常规操作

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hzhj2007/article/details/81514710
  1.  指定基础镜像
  2. 修改下载源
  3. 移动文件
  4. 复制文件
  5. 设定环境变量
  6. 设定目录地址
  7. 设定开放端口
  8. 设定启动文件

如下是针对Detectron的dockerfile文件修改后内容。

# Use Caffe2 image as parent image
FROM caffe2ai/caffe2:c2.cuda8.cudnn5.ubuntu16.04  #基础镜像

RUN sed -i "s#archive.ubuntu.com#mirrors.aliyun.com#g" /etc/apt/sources.list \
    && sed -i "s#security.ubuntu.com#mirrors.aliyun.com#g" /etc/apt/sources.list #修改下载源

RUN mv /usr/local/caffe2 /usr/local/caffe2_build #移动本地文件
ENV Caffe2_DIR /usr/local/caffe2_build #设定环境变量

ENV PYTHONPATH /usr/local/caffe2_build:${PYTHONPATH}
ENV LD_LIBRARY_PATH /usr/local/caffe2_build/lib:${LD_LIBRARY_PATH}

# Clone the Detectron repository
RUN git clone https://github.com/facebookresearch/detectron /detectron #下载工程至指定目录

# Install Python dependencies
RUN pip install -r /detectron/requirements.txt

# Install the COCO API
RUN apt-get install unzip #安装文件
COPY cocoapi.zip /     #复制本地文件至指定目录
WORKDIR /              #设定当前工作目录
RUN unzip cocoapi.zip \
    && rm cocoapi.zip
WORKDIR /cocoapi/PythonAPI
RUN make install

EXPOSE 7001  #开放镜像端口
ENTRYPOINT ["/bin/sh", "start_proc.sh"] #启动镜像后执行的文件

运行Dockerfile文件命令:

docker build -f Dockerfile  -t thub.auto.com.cn/dmcv/detectron:test .  #注意末尾的.

参考文献:

  1. https://github.com/facebookresearch/Detectron

猜你喜欢

转载自blog.csdn.net/hzhj2007/article/details/81514710