当前位置:   article > 正文

docker篇---docker-compose和dockerfile构建镜像_docker compost 构建镜像

docker compost 构建镜像

docker-compose和dockerfile构建镜像

docker-compose

该docker-compose 将主项目与 mongo和nvidia 这两个镜像联系在一起,作为依赖

version: '3.8'
services:
  my_project:
    build: project
    container_name: "object-detection"
    volumes:
      - /home/aaa/project_object/num_1/project:/code
    ports:
      - "2223:22"
    depends_on:
      - mongo
    runtime: nvidia

  mongo:
    image: mongo:3.4
    container_name: "mongo_34"
    restart: always
    ports:
      - "27017:27017"
    volumes:
      - ./mongo/data:/data/db


  nvidia:
    image: nvidia/cuda:11.0-base
    command: nvidia-smi
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [ gpu, utility ]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33

Dockerfile

FROM python:3.7

ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility

WORKDIR /code
COPY . .
RUN apt-get update
RUN apt-get install vim ffmpeg libsm6 libxext6 cron openssh-server -y
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt

# 修改容器時間
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai'>/etc/timezone

RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/'  /etc/ssh/sshd_config
RUN sed -i 's/UsePAM yes/UsePAM no/' /etc/ssh/sshd_config
RUN echo "root:123456" | chpasswd

RUN echo  "alias ll='ls -l'" >> ~/.bash_profile
RUN /bin/bash -c 'source  ~/.bash_profile;'

CMD ["python","app.py"]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/666209
推荐阅读
相关标签
  

闽ICP备14008679号