Docker container 安装

艾安和
2023-12-01
# build_dockerfile.sh 内容:
docker build -t sudipan/pytorch1_7-cuda11_cudnn8 .

# build docker_container.sh 内容:
docker run --runtime=nvidia -it --ipc=host \
-v /mnt/sudipan/:/home/ \
sudipan/pytorch1_7-cuda11_cudnn8
sh build_dockerfile.sh

sh build_container.sh

docker ps -all

docker start ID

docker attach ID



具体细节如下:


jianhua@ai4eo1:~/dockerImageConfig1$ docker ps -all
CONTAINER ID        IMAGE                              COMMAND             CREATED             STATUS                            PORTS               NAMES
cf58ffaced83        jianhua/pytorch1_7-cuda11_cudnn8   "/bin/sh -c bash"   2 minutes ago       Exited (130) About a minute ago                       cranky_gates
jianhua@ai4eo1:~/dockerImageConfig1$ docker start cf58ffaced83
cf58ffaced83
jianhua@ai4eo1:~/dockerImageConfig1$ docker attach cf58ffaced83

get the container ID

docker ps -a

or 
docker ps


running the container--- get into the container

docker start ID_NUMBER
docker attach ID_NUMBER


jianhua@ai4eo1:~$ docker start beeb40100d59
beeb40100d59
jianhua@ai4eo1:~$ docker attach beeb40100d59
root@beeb40100d59:/home/user#

getback to the home
root@beeb40100d59:/home/user# cd ..

show the documents i have
root@beeb40100d59:/home# ls
Anaconda3-2021.05-Linux-x86_64.sh  pix2pix  user

into the pix2pix document
root@beeb40100d59:/home# cd pix2pix
root@beeb40100d59:/home/pix2pix#





再次编译建立另一个container
jianhua@ai4eo1:~/dockerImageConfig1$ sh build_dockerfile.sh
Sending build context to Docker daemon   5.12kB
Step 1/28 : FROM pytorch/pytorch:1.7.0-cuda11.0-cudnn8-runtime
 ---> f8a1d10ae3d7
Step 2/28 : MAINTAINER Jianhua
 ---> Using cache
 ---> ca8e646609a3
。。。。。。。。
Step 27/28 : WORKDIR ${workdir}
 ---> Using cache
 ---> 3c4db653502a
Step 28/28 : CMD bash
 ---> Using cache
 ---> 19fef1150335
Successfully built 19fef1150335
Successfully tagged jianhua/pytorch1_7-cuda11_cudnn8:latest
jianhua@ai4eo1:~/dockerImageConfig1$ sh build_container.sh
root@cf58ffaced83:/home/user# docker ps

jianhua@ai4eo1:~/dockerImageConfig1$ docker ps -all
CONTAINER ID        IMAGE                              COMMAND             CREATED             STATUS                            PORTS               NAMES
cf58ffaced83        jianhua/pytorch1_7-cuda11_cudnn8   "/bin/sh -c bash"   2 minutes ago       Exited (130) About a minute ago                       cranky_gates
jianhua@ai4eo1:~/dockerImageConfig1$ docker start cf58ffaced83
cf58ffaced83
jianhua@ai4eo1:~/dockerImageConfig1$ docker attach cf58ffaced83

 类似资料: