-part 1 ubuntu16.04 + docker安装
链接 [link]https://blog.csdn.net/weixin_41270857/article/details/83449123
-part 2 Dockerfile + nvidia docker
链接 [link]https://blog.csdn.net/weixin_41270857/article/details/83449964
首先简单的介绍一下docker,内容参考docker中文社区入门教程:[link] http://www.docker.org.cn/book/docker/what-is-docker-16.html
Docker是一个开源的引擎,可以轻松的为任何应用创建一个轻量级的、可移植的、自给自足的容器。开发者在笔记本上编译测试通过的容器可以批量地在生产环境中部署,包括VMs(虚拟机)、bare metal、OpenStack 集群和其他的基础应用平台。
Docker通常用于如下场景:
docker的安装参考官网,这里只是简单的翻译并总结了一下,docker分为dockerCE和dockerEE两个版本,dockerCE针对个人用户。因此这里在Ubuntu16.04上安装dockerCE,官网安装教程链接[link]https://docs.docker.com/install/
$ sudo apt-get remove docker docker-engine docker.io
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
$ sudo apt-get update
$ sudo apt-get install docker-ce
$ sudo docker run hello-world
结果如下
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
安装完成后如果当前用户为非root用户的话运行docker run hello-world命令会报错Got permision denied ,为了避免每次都需要sudo运行docker,因此创建一个docker 用户组
,但是需要注意的是此时docker 用户组等同于root账户,具体参考官网教程[link]https://docs.docker.com/install/linux/linux-postinstall/
$ sudo groupadd docker
$ sudo usermod -aG docker $USER
$ sudo systemctl restart docker
本部分建议直接阅读官网教程[link]https://docs.docker.com/get-started/ ,这里只是简单的列举了一些常用命令
## 查看docker版本和信息
docker --version
docker version
docker info
## 运行docker容器
docker run hello-world
## 查看docker镜像
docker image ls
## 查看docker容器
docker container ls
docker container ls --all
docker container ls -aq
[1]: [link] http://www.docker.org.cn/book/docker/what-is-docker-16.html
[2]: [link]https://docs.docker.com/install/
[3]: [link]https://docs.docker.com/install/linux/linux-postinstall/
[4]: [link]https://docs.docker.com/get-started/