Ubuntu 16.04安装使用Docker

版权声明:本文为博主原创文章,未经博主允许不得转载。
题记
安装系列一篇,最近闲暇来折腾折腾docker和spring boot。记录步骤,简要说明,目的是能够快速安装使用,方便查阅,这就是写安装文章的作用,我个人不喜欢写很多参数说明,有兴趣的人自会去深入阅读官方文档说明,就像app的理念一样,一次只做好一件事。
Linux环境
Ubuntu 16.04(LTS)
简单方法
$ sudo apt-get update
$ sudo apt-get install docker
搞定!
但是这种方法有一个缺点:安装的不一定是最新的docker,安装版本是1.10.2,不过,对于docker使用没任何什么问题,如果要后续升级方便,可以使用下面的方法。
另一种方法
1.切换到root权限或者用sudo
2.升级source列表并保证https和ca证书成功安装
# apt-get update
# apt-get install apt-transport-https ca-certificates
3.增加新的GPG 密钥
# apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
4.新增或编辑source列表里的docker.list文件
# vi /etc/apt/sources.list.d/docker.list //如果不存在就新增
5.删除已有的entries
6.按照系统版本增加entry(Ubuntu Xenial 16.04 (LTS))
deb https://apt.dockerproject.org/repo ubuntu-xenial main
7.重新执行更新操作,并删除老的repo
# apt-get purge lxc-docker //没有安装的话,跳过
8.查看是否有正确的可用版本
# apt-cache policy docker-engine
如图:
9.从14.04版本以上开始docker推荐安装linux-image-extra
# apt-get install linux-image-extra-$(uname -r)
10.安装docker
# apt-get update
# apt-get install docker-engine
# service docker start
# docker run hello-world
到此结束,the end!
page 155 of 366 in chapter 2016
--------------------------------------------------------- // -------------------------------------------
下面的内容有点问题,需要注意。
blog.youkuaiyun.com/u011987514/article/details/70943378
Caffe的GPU环境搭建在docker支持下并不困难,但是过程比较杂
所需依赖如下,本文会说明安装方法,帮助大家少走弯路
- GNU/Linux x86_64 with kernel version > 3.10
- Docker >= 1.9 (official
docker-engine
,docker-ce
ordocker-ee
only) - NVIDIA GPU with Architecture > Fermi (2.1)
- NVIDIA drivers >= 340.29 with binary
nvidia-modprobe
本文分成三部分总结
1.Docker安装与配置
2.Cuda安装
3.Caffe安装
一、Docker安装与配置
1.设置repository
- sudo apt-get -y install \
- apt-transport-https \
- ca-certificates \
- curl
- 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
2.获取Docker CE
- sudo apt-get -y install docker-ce
3.测试是否安装成功
- docker info
4. 安装nvidia-docker
- # Install nvidia-docker and nvidia-docker-plugin
- wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
- sudo dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb
- zcw@ubuntu:~# mkdir docker
- zcw@ubuntu:~# vim /etc/default/docker
- DOCKER_OPTS="--graph=/home/docker"
- service docker restart
- zcw@ubuntu:~# mkdir -p /etc/systemd/system/docker.service.d
- zcw@ubuntu:~# cat /etc/systemd/system/docker.service.d/Using_Environment_File.conf
- [Service]
- EnvironmentFile=-/etc/default/docker
- ExecStart=
- ExecStart=/usr/bin/docker daemon -H fd:// $DOCKER_OPTS
- zcw@ubuntu:~# systemctl daemon-reload
- zcw@ubuntu:~# service docker restart
docker run --rm -u $(id -u):$(id -g) -v $(pwd):$(pwd) -w $(pwd) bvlc/caffe:gpu caffe train --solver=example_solver.prototxt
Docker Engine Utility for NVIDIA GPUs
Documentation
The full documentation is available on the repository wiki.
A good place to start is to understand why nvidia-docker is needed in the first place.
Quick start
Assuming the NVIDIA drivers and Docker® Engine are properly installed (see installation)
Ubuntu distributions
# Install nvidia-docker and nvidia-docker-plugin
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
sudo dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb
# Test nvidia-smi
nvidia-docker run --rm nvidia/cuda nvidia-smi
CentOS distributions
# Install nvidia-docker and nvidia-docker-plugin
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker-1.0.1-1.x86_64.rpm
sudo rpm -i /tmp/nvidia-docker*.rpm && rm /tmp/nvidia-docker*.rpm
sudo systemctl start nvidia-docker
# Test nvidia-smi
nvidia-docker run --rm nvidia/cuda nvidia-smi
Other distributions
# Install nvidia-docker and nvidia-docker-plugin
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1_amd64.tar.xz
sudo tar --strip-components=1 -C /usr/bin -xvf /tmp/nvidia-docker*.tar.xz && rm /tmp/nvidia-docker*.tar.xz
# Run nvidia-docker-plugin
sudo -b nohup nvidia-docker-plugin > /tmp/nvidia-docker.log
# Test nvidia-smi
nvidia-docker run --rm nvidia/cuda nvidia-smi
ppc64le (POWER) Archictecture
There is limited build support for ppc64le. Running make deb
will build the nvidia-docker deb for ppc64le (if run on a ppc64le system). If the deb install fails because you have the 'docker.io' (>= v1.9) package installed, but not the 'docker-engine' package, you can force-install. There is currently no docker-provided docker-engine repository for ppc64le.
Not all the build targets for ppc64le have been implemented. If you would like for a Dockerfile to be created to enable a ppc64le target, please open an issue.
Issues and Contributing
A signed copy of the Contributor License Agreement needs to be provided to digits@nvidia.com before any change can be accepted.
- Please let us know by filing a new issue
- You can contribute by opening a pull request