0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

How-to-Use-Python-in-Docker

Posted at

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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?