北冥有鱼 记录生活点滴,分享学习心得

Docker容器/镜像备份命令

Posted by YuChen on March 23, 2020

保存容器修改

1
2
sudo docker commit -a "paddle" -m "backup" d194406b113f paddlepaddle/paddle:latest-gpu-cuda10.0-cudnn7-dev
# -a:修改者信息 -m:注释、说明 紧跟着当前操作的容器id 最后是要生成的新的镜像名称

保存镜像

1
sudo docker save -o paddle_v100.tar paddlepaddle/paddle:latest-gpu-cuda10.0-cudnn7-dev

导入镜像

1
sudo docker load<paddle_v100.tar

导出容器

1
2
3
docker export -o my_container.tar <CONTAINER ID>
或者
docker export <CONTAINER ID> > my_container.tar

导入容器为镜像

1
cat my_container.tar | docker import - image_name:tag

示例:

1
cat docker-backup/paddle_dev_img.tar | sudo /usr/bin/docker import - paddlepaddle/paddle:vim-dev&

查看导入的镜像

1
docker images

运行导入的镜像

1
sudo nvidia-docker run --ulimit core=-1 --security-opt seccomp=unconfined --net=host --name container_name -it -v $PWD/.cache:/root/.cache -v $PWD:/work image_name:tag /bin/bash

ulimit -c unlimited —— 调试使用,生成core dump

示例:

1
sudo docker run --ulimit core=-1 --security-opt seccomp=unconfined --net=host --name paddle_gpu -it -v $PWD/.cache:/root/.cache -v $PWD:/work paddlepaddle/paddle:vim-dev /bin/bash

Docker中的关于cuda的配置

1
2
3
4
5
6
7
8
export LD_LIBRARY_PATH=/root/.virtualenvs/paddlepaddle-venv/lib/python2.7/site-packages/paddle/libs:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/work/cuda/cuda-9.0/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/work/cuda/cudnn/cudnn_v7/cuda/lib64:$LD_LIBRARY_PATH
export LIBRARY_PATH=/work/cuda/cuda-9.0/lib64:$LIBRARY_PATH
export LIBRARY_PATH=/work/cuda/cudnn/cudnn_v7/cuda/lib64:$LIBRARY_PATH
export CPLUS_INCLUDE_PATH=/work/cuda/cuda-9.0/include:$CPLUS_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/work/cuda/cudnn/cudnn_v7/cuda/include:$CPLUS_INCLUDE_PATH
export PATH=/work/cuda/cuda-9.0/bin:$PATH




更多文章