docker 공식 문서에 따라 설치를 진행하면 된다.
# delete old version
sudo apt-get remove docker docker-engine docker.io containerd runc
# install dependency
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
# add official gpg key & verify
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
# pub rsa4096 2017-02-22 [SCEA]
# 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
# uid [ unknown] Docker Release (CE deb) <docker@docker.com>
# sub rsa4096 2017-02-22 [S]
# add repo
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
# install lastest version
sudo apt-get update
sudo apt-get install -y docker-ce
# 로그인 한 계정에 docker 그룹을 추가
sudo usermod -aG docker $USER
sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
sudo apt-get purge -y nvidia-docker
# Add the package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
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
# Install nvidia-docker2 and reload the Docker daemon configuration
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd
# Test nvidia-smi with the latest official CUDA image
docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi
docker에서 python을 이용하는 가장 쉬운 방법은 원하는 버전이 설치된 이미지를 다운로드 받아서 사용하는 것이겠지만 경우에 따라서는 직접 설치해야하는 경우가 있다.
apt-get update
apt-get install -y software-properties-common # ubuntu18.04 에서 python3.6.9 가 설치됨
add-apt-repository -y ppa:deadsnakes/ppa
apt-get update;
apt-get install -y python3.7 python3.7-dev python3.7-distutils curl
update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1
curl https://bootstrap.pypa.io/get-pip.py | python # install pip