docker构建自己的镜像
生活随笔
收集整理的這篇文章主要介紹了
docker构建自己的镜像
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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,得到如下窗口:
- 查看當前所有的鏡像
- 使用run命令運行鏡像
其中-it表示交互式的啟動容器,并且有新的命令窗口出現
-v表示掛載主機中的文件夾到容器中,必須是絕對路徑
- 使用build命令構建鏡像
cd到相應路徑
執行如下命令
改路徑下應該有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/總結
以上是生活随笔為你收集整理的docker构建自己的镜像的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端学习(541):node得优势
- 下一篇: 使用IE缓存提取微博相片