zoukankan      html  css  js  c++  java
  • docker 使用

    头一次使用记录一下过程,方便下次过来粘贴

    一、构建dockerfile

    下面代码存在文件,命名:dockerfile

    注意: RUN 尽量合起来写,因为每运行一个RUN都会构建一个新的镜像,下一步在上一步形成的镜像上构建

    FROM python:3.6
    WORKDIR /code/
    STOPSIGNAL SIGINT
    COPY ./ /code/
    RUN pip --no-cache-dir install PyMySQL==0.9.3 
        && pip --no-cache-dir install redis==3.2.1 
        && mkdir /opt/log/ 
        && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 
        && echo 'Asia/Shanghai' >/etc/timezone 
        && echo "python test.py >> /opt/log/test_log.log 2>&1"> run.sh
    CMD ["sh", "run.sh"]

    二、build 构建镜像

    docker build -f dockerfile -t 镜像名称:版本 .
    # 列子
    docker build -f dockerfile -t test . # 不加班本就是最后一版

    三、执行 docker run 运行容器

    docker run -v /opt/log:/opt/log --name=test_docker -d test
    # -v 挂载数据在宿主机上
    # --name 起个名字
    # -d 在后台运行

    注: 简单的瞎记一下使用过程,没写什么解释,就是为了方便复制粘贴用

  • 相关阅读:
    python flask学习笔记
    语音识别2 -- Listen,Attend,and Spell (LAS)
    语音识别 1--概述
    keras中seq2seq实现
    ResNet模型
    Bytes类型
    Python操作文件
    Pyhon基本数据类型
    ping
    find
  • 原文地址:https://www.cnblogs.com/Frange/p/13899006.html
Copyright © 2011-2022 走看看