Windows系统

作者的是win10系统
参考网址http://www.runoob.com/docker/windows-docker-install.html

下载docker toolbox

https://docs.docker.com/toolbox/overview/
并安装,得到如下结果
在这里插入图片描述

构建自己的镜像

  • 寻找适合自己的基础镜像
    在网站https://hub.docker.com搜索适合自己的基础镜像
  • 使用命令pull下载镜像
    打开docker quick start,得到如下窗口:
    在这里插入图片描述
docker pull nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
  • 查看当前所有的镜像
docker images
  • 使用run命令运行镜像
docker run -it -v (主机绝对路径):(容器绝对路径) XX/XX:XXX

其中-it表示交互式的启动容器,并且有新的命令窗口出现
-v表示挂载主机中的文件夹到容器中,必须是绝对路径

  • 使用build命令构建镜像
    cd到相应路径
    执行如下命令
docker build XX/XX:XXX .

改路径下应该有Dockerfile文件,内容如下:

FROM nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
LABEL maintainer "gphsmail@163.com"

# tsinghua
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak
RUN echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse">>/etc/apt/sources.list && \
    echo "deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse">>/etc/apt/sources.list && \
    echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse">>/etc/apt/sources.list && \
    echo "deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse">>/etc/apt/sources.list && \
    echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse">>/etc/apt/sources.list && \
    echo "deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse">>/etc/apt/sources.list && \
    echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse">>/etc/apt/sources.list && \
    echo "deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse">>/etc/apt/sources.list && \
    apt-get update

# install vim
RUN apt-get update && \
	apt-get install -y vim

# install python and pip
RUN apt-get install -y python3.5 && \
    apt-get install -y python3-pip && \
    ln -sf /usr/bin/python3.5 /usr/bin/python && \
    echo "export PYTHONPATH=/usr/bin/python:$PYTHONPATH">>~\.bashrc

# change source pip
RUN mkdir ~/.pip && \
    echo "[global]" > ~/.pip/pip.conf && \
    echo "index-url = https://pypi.tuna.tsinghua.edu.cn/simple" >> ~/.pip/pip.conf && \
    echo "trusted-host = pypi.tuna.tsinghua.edu.cn" >> ~/.pip/pip.conf

# install openface denpendences
RUN apt-get install -y cmake && \
    apt-get install -y libopenblas-dev && \
    apt-get install -y libboost-all-dev

#install opencv
RUN apt-get install -y git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
RUN apt-get install -y python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev
#set python3 default
RUN update-alternatives --install /usr/bin/python python /usr/bin/python2 100 
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 150
COPY data/opencv-3.4.4/ /home/opencv-3.4.4/
RUN cd /home/opencv-3.4.4/ && mkdir build && cd build && \
    cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_TIFF=ON -D WITH_TBB=ON -D BUILD_SHARED_LIBS=OFF .. && \
    make -j2 && make install

# install dlib
COPY data/dlib-master/ /home/dlib-master/
RUN cd /home/dlib-master/ && mkdir build && cd build && \
    cmake .. && cmake --build . --config Release && \
    make install && ldconfig

# install openface
COPY data/OpenFace-master/ /home/OpenFace-master/
RUN cd /home/OpenFace-master/ && mkdir build && cd build && \
    cmake -D CMAKE_BUILD_TYPE=RELEASE CMAKE_CXX_FLAGS="-std=c++11" -D CMAKE_EXE_LINKER_FLAGS="-std=c++11" .. && \
    make
COPY data/patch_experts/ /home/OpenFace-master/build/bin/model/patch_experts/
Logo

云原生社区为您提供最前沿的新闻资讯和知识内容

更多推荐