美文网首页
2018-07-10

2018-07-10

作者: 无善无恶 | 来源:发表于2018-07-10 17:09 被阅读25次

    dockerfile语法

    • 常用的关键字:

    FROM

    RUN

    USER

    ADD

    • 符号:

    &&

    /

    • 切换源:

    pip install -i

    conda install -c

    docker命令

    docker run -it image_name

    docker build -t iamge_name .

    docker tag 【image_id】 【iamge_full_name】
    docker images | grep 【key_word】

    docker push 【image_full_name】

    docker pull 【image_full_name】

    注意:

    image_full_name :【server_host]】/ 【project_root】 / 【name】: 【tag】

    build成功后可以通过docker run 启动一个 container ,通过 conda list | greep *** 查看安装的库是否有冲突:

    root@239b60aff0c6:~# conda list | grep numpy
    numpy 1.14.5 py36hcd700cb_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    numpy 1.14.5 <pip>
    numpy-base 1.14.5 py36hdbf6ddf_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    root@239b60aff0c6:~# conda list | grep keras
    keras 2.2.0 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    keras-applications 1.0.2 py_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    keras-base 2.2.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    keras-gpu 2.2.0 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    keras-preprocessing 1.0.1 py_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    root@239b60aff0c6:~# conda list | grep mxnet
    mxnet-cu92 1.2.0 <pip>
    root@239b60aff0c6:~# conda list | grep pytorch
    cuda90 1.0 h6433d27_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
    pytorch 0.4.0 py36_cuda9.0.176_cudnn7.1.2_1 [cuda90] https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
    torchvision 0.2.1 py36_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
    root@239b60aff0c6:~# conda list | grep scipy
    scipy 1.1.0 <pip>
    scipy 1.1.0 py36hfc37229_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    root@239b60aff0c6:~# conda list | grep matl
    root@239b60aff0c6:~# conda list | grep matplot
    matplotlib 2.2.2 <pip>
    root@239b60aff0c6:~# conda list | grep pandas
    pandas 0.23.1 <pip>

    例子

    FROM docker.io/deepintelligent/tensorflow-1.8.0-notebook-gpu
    USER root

    ADD sources.list /etc/apt/

    RUN conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ &&
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ &&
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/noarch &&
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ &&\

    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ &&\

    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ &&\

    conda config --set show_channel_urls yes
    RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple mxnet-cu92
    RUN conda install keras-gpu
    RUN conda install -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ pytorch torchvision cuda90 -c pytorch

    RUN conda config --set ssl_verify no

    RUN conda install -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/ caffe2 caffe2-cuda8.0-cudnn7

    命令例子

    [root@st1-deepintelligent-1] /data4/huineng/gpu$docker tag 01720871f2ae mangan-prod-3.srv.yiran.com/deepintelligent/tensorflow-keras-mxnet-pytorch-gpu:20180710-v1

    [root@st1-deepintelligent-1] /data4/huineng/gpu$ docker push ccr.ccs.tencentyun.com/deepintelligent/tensorflow-keras-mxnet-pytorch-gpu:20180710-v1

    kubectl describe pod -n=tfworkflow jupyter-huineng

    [root@adml9st] /data3$ docker pull ccr.ccs.tencentyun.com/deepintelligent/tensorflow-keras-mxnet-pytorch-gpu:20180710-v1

    相关文章

      网友评论

          本文标题:2018-07-10

          本文链接:https://www.haomeiwen.com/subject/oqlqpftx.html