通过dockerfile构建tensorflow+opencv+jupyter+otherlibs的镜像(ubuntu+python3+ffmpeg+python-dev)

本dockerfile是在通过dockerfile构建tensorflow+opencv的镜像(ubuntu+python3+ffmpeg)基础上增加是jupyter的相关安装。

 

步骤1:编写Dockerfile

步骤2:安装镜像

步骤3:验证安装

 

步骤1:编写Dockerfile

 1、在目录/dockerfiles/tensorflow-opencv-jupyter--otherlibs下创建一个Dockerfile

mkdir /dockerfiles

mkdir /dockerfiles/tensorflow-opencv-jupyter-otherlibs

vi /dockerfiles/tensorflow-opencv-jupyter-otherlibs/Dockerfile

2、Dockerfile的内容如下:

FROM ubuntu:16.04

RUN  apt-get update
RUN  apt-get upgrade -y

# Install python3
RUN  apt-get install -y python3 

# Install pip
RUN apt-get install -y wget vim
RUN wget -O /tmp/get-pip.py https://bootstrap.pypa.io/get-pip.py
RUN python3 /tmp/get-pip.py
RUN pip install --upgrade pip

# Install other libs
RUN  pip install -U numpy
RUN  pip install -U matplotlib
RUN  pip install -U pandas

# Install tensorflow
RUN pip install -U tensorflow

# Install ffmpeg
RUN  apt-get install -y ffmpeg

# Install moviepy
RUN  pip install -U moviepy

# Install cmake
RUN apt-get update
RUN apt-get install -y build-essential
RUN apt-get install -y cmake

# Install OpenCV
RUN apt-get install -y unzip
RUN wget -P /usr/local/src/ https://github.com/opencv/opencv/archive/3.4.1.zip
RUN cd /usr/local/src/ && unzip 3.4.1.zip && rm 3.4.1.zip
RUN cd /usr/local/src/opencv-3.4.1/ && mkdir build
RUN cd /usr/local/src/opencv-3.4.1/build && cmake -D CMAKE_INSTALL_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/ .. && make -j4 && make install


# Install opencv-python
RUN pip install opencv-python
RUN apt-get install -y libsm6
RUN apt-get install -y libxrender1
RUN apt-get install -y libxext-dev


# Install python-dev
RUN apt-get update
RUN apt-get install -y python-dev

# Install jupyter notebook
RUN pip install  jupyter
RUN pip install  notebook


由于numpy和tensorflow的有版本冲突,所以numpy等的基础libs必须在tensorflow前进行安装

步骤2:安装镜像

docker build -t lld2002/python3-tensorflow-opencv-jupyter-otherlibs /dockerfiles/tensorflow-opencv-jupyter-otherlibs

步骤3:验证安装

1、通过镜像生成容器,并运行

docker run -it lld2002/python3-tensorflow-opencv-jupyter-otherlibs:latest /bin/bash

2、在容器的终端中,创建一个/test.py的文件

vi /test.py

3、test.py的内容如下:

import tensorflow as tf
import numpy as np
import matplotlib as mlib
import pandas

4、运行/test.py

python3 /test.py

控制台无报错

则测试成功

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值