docker 常用指令
https://zhuanlan.zhihu.com/p/78541520 --知乎docker部署深度学习环境
https://www.cnblogs.com/journeyonmyway/p/11234732.html
----基于nvidia/cuda的深度学习基础镜像构建流程 V0.2
安装tensorflow镜像:
nvcr.io/nvidia/tensorflow:18.12-py3
sudo docker pull nvcr.io/nvidia/tensorflow:1.8.0-gpu-py3
sudo docker pull tensorflow/tensorflow:1.14.0-gpu
sudo docker pull tensorflow/tensorflow:1.8.0-gpu
docker pull tensorflow/tensorflow:1.8.0-gpu-py3
安装pytorch镜像: 配置cabinet-pytorch-docker环境
以这个镜像为基础,将host的cuda-10.0文件夹替换 docker内的cuda文件夹,才通过。
sudo docker pull anibali/pytorch:cuda-10.0
1、创建容器:
sudo docker run --name torch_docker0 --gpus all -it 72b4573fd1c4 /bin/bash
sudo nvidia-docker run --name uninet_docker_tf1.8 -it -v /media/cv/DataB/xj/Docker_examples/:/data --gpus all 3c57055e68a2 /bin/bash
sudo nvidia-docker run --name cabinet_pytorch_v1 –gpus all --memory="10g" --memory-swap="12g" --shm-size="5g" -v /media/cv/DataB/xj/Docker_examples/:/data -it cabinet_pytorch:1.0 /bin/bash
镜像提交 commit:
docker commit:提交容器副本使之成为一个新的镜像
docker commit -a="作者名" -m="提交的描述信息" 容器id 新建的镜像名称:标签名
例子:docker commit -a="wu-wu" -m="red tomcat" eb4187f8edd4 mytomcat:1.1
docker commit -a="xj" -m="torch docker" eb4187f8edd4 mytomcat:1.0
生成一个版本为1.1的名叫mytomcat镜像
3、docker-修改容器的挂载目录
方式二:提交现有容器为新镜像,然后重新运行它
docker commit -a="xj" -m="torch docker" eb4187f8edd4 mytomcat:1.0
docker run -ti -v "$PWD/dir1":/dir1 -v "$PWD/dir2":/dir2 newimagename /bin/bash
sudo docker run --name torch_docker1 -it -v /media/cv/DataB/xj/Docker_examples/:/data --gpus all torch_docker0.1 /bin/bash
nvidia-docker run --name yolo_resnet -v /home/caros/xujun:/data -it 4b0cd6af9d68 bash
sudo docker run -d --privileged=true --runtime=nvidia --gpus all --net=host -v /dev:/dev -v /data/autocar:/home/mogo/data --restart=always --name 镜像名 autocar_****_test
4、重命名Docker容器
重命名Docker容器:
docker rename [Old container name] [New container name]
5、将docker镜像保存,部署到其他机器
https://www.cnblogs.com/bigben0123/p/7592970.html
1、docker save -o 要保存的文件名 要保存的镜像
docker save -o cabinet_pytorch.tar cabinet_pytorch:1.0
2、拷贝到指定机器后,载入镜像
https://www.jianshu.com/p/4e862a2a2d03
拷贝指令: scp ***.tar navinfo@172.23.132.119:/media/DataA/***/
docker load --input 文件
docker load -i cabinet_pytorch.tar
/etc/docker/daemon.json
默认:
{
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
}
}
改为了:
{
"registry-mirrors": [
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
]
}
重启docker:
service docker restart
或:
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
6. gitlab操作
Command line instructions
You can also upload existing files from your computer using the instructions below.
Git global setup:
git config --global user.name "**05730"
git config --global user.email "**@***.com"
Create a new repository:
git clone https://gitlab.navinfo.com/xujun/parking_wall_flask.git
cd parking_wall_flask
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Push an existing folder:
cd existing_folder
git init
git remote add origin https://gitlab.navinfo.com/xujun/parking_wall_flask.git
git add .
git commit -m "Initial commit"
git push -u origin master
Push an existing Git repository:
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.navinfo.com/xujun/parking_wall_flask.git
git push -u origin --all
git push -u origin --tags