How to get started with Docker

How to get started with Docker


1. Install

curl -fsSL https://get.docker.com/ | sudo sh
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
sudo systemctl restart docker
sudo usermod -aG docker $USER # 현재 접속중인 사용자에게 권한주기
sudo usermod -aG docker carrot
sudo reboot

2. Docker Image download

pytorch docker nvcr>=21.05 by nvidia image image
Copy Image Path

@terminal

docker pull nvcr.io/nvidia/pytorch:21.05-py3
docker images

image

3. Build and runs docker containers

docker run -it --gpus all --name Swintransformer nvcr.io/nvidia/pytorch:21.05-py3 /bin/bash

image @container

pip freeze  #python labraries
python -V #python version
python #run python

4. Stop Containers

This is only possible when the -it option is given and created when the container is created.

>> ctrl + P
>> ctrl + Q

5. Exit Containers

>> exit
or
>> ctrl + D

6. Start Containers

docker ps -a # Check the list of containers

image

docker start Swintransformer
docker attach Swintransformer