target: use Python in container
make Dockerfile
python-on-docker/Dockerfile
FROM ubuntu:22.04
RUN apt update
RUN apt install -y python3.10
RUN apt install -y python3-pip
build Docker image
docker build -t python-on-docker .
if you mistake building doker image, you can delete it
docker rmi [image name]
confirm making Docker image correctly
docker images
run Dockerfile
docker run -it --shm-size 16g python-on-docker
if you want to use GPU, run this command instead.
docker run -it --gpus all --shm-size 16g python-on-docker
Python
python3
quit()
GPU
python3
import torch
torch.cuda.device_count()
quit()
copy file
if you want to copy file from container outside.
docker cp path-to-file [CONTAINER-ID]:/abs/dir
if you want to copy file for container outside.
docker cp [CONTAINER-ID]:/abs-file-path to-file-dir