Container
Container 확인
nvidia-docker ps # 현재 사용하고 있는 container확인
Container attach
sudo docker attach <container id 또는 이름>
Container 삭제
sudo docker rm <container id 또는 이름>
Image
docker파일로 image 생성
docker build -t <이미지 이름>:<tag> <docker file 경로>
# tag 지정 안하면 자동으로 latest로 됨
docker파일 예시
FROM pytorch/pytorch:1.4-cuda10.1-cudnn7-devel
MAINTAINER (이름)
RUN apt-get update
RUN apt-get install -y wget
RUN apt-get install -y tmux
RUN apt-get install -y reptyr
RUN pip install tensorboardX
RUN pip install scipy pillow
RUN pip install opencv-contrib-python
RUN pip install torchvision
RUN pip install scikit-image
RUN pip install flake8
RUN pip install isort
RUN pip install ptflops
WORKDIR /root/
생성된 image 확인
nvidia-docker images
image 삭제
docker rim <image 이름 또는 id>:<tag>
# tag 지정 안하면 latest tag 삭제
container 상태를 image에 commit ( container 기반으로 image를 생성 또는 업데이트 )
docker commit <container id 또는 이름> <image 이름>:<tag>
image 이름 바꿔서 복사
docker image tag <기존의 이미지명>:<기존의 태그명> <새로운 이미지명>:<새로운 태그명>
Docker 실행
nvidia-docker run -v <마운트할 디렉토리> -it --name <container 이름> --rm <이미지 이름>:<tag> /bin/bash
https://keyog.tistory.com/43 참고
옵션 | 설명 |
-p | 호스트와 컨테이너의 포트를 연결 (포워딩) |
-v | 호스트와 컨테이너의 디렉토리를 연결 (마운트) |
-name | 컨테이너 이름 설정 |
-rm | 프로세스 종료시 컨테이너 자동 제거 |
-it | -i와 -t를 동시에 사용한 것으로 터미널 입력을 위한 옵션 |
Docker hub
docker hub login
docker login
# Username:
# Password:
# docker login 명령어를 치면 id와 password를 적도록 나온다.
image를 docker hub에 올리기 (push)
docker push <image이름>:tag
여기서 image이름은 예를들어 ' <username>/pytorch1.5.1:tag ' 형태로 ' / '앞에는 본인 docker hub 계정 id(username)여야 한다.
image를 docker hub에서 가져오기 (pull)
docker pull <image이름>:tag
docker hub에 공개되어 있는 모든 image들을 가져올 수 있다.
'개발환경 > Docker' 카테고리의 다른 글
[Docker] Docker를 이용한 모델 학습 루틴, image 관리 (2022 이전) (0) | 2022.06.19 |
---|---|
[Docker] Docker 컨테이너에서 Tensorboard 사용하기 (0) | 2022.06.18 |