网站广告图片在线制作,南宁seo推广优化,wordpress中文网站优化,wordpress自己写插件吗Ubuntu 系统下Docker安装与使用Docker安装与使用Docker安装安装环境准备工作系统要求卸载旧版本Ubuntu 14.04 可选内核模块Ubuntu 16.04 使用 APT 安装安装 Docker CE使用脚本自动安装启动 Docker CE建立 docker 用户组测试 Docker 是否安装正确镜像加速Docker使用拉取镜像创建…
Ubuntu 系统下Docker安装与使用Docker安装与使用Docker安装安装环境准备工作系统要求卸载旧版本Ubuntu 14.04 可选内核模块Ubuntu 16.04 使用 APT 安装安装 Docker CE使用脚本自动安装启动 Docker CE建立 docker 用户组测试 Docker 是否安装正确镜像加速Docker使用拉取镜像创建容器查看本地镜像删除镜像运行容器查看容器运行情况停止容器销毁容器docker中常见的错误参考文档Docker安装与使用
Docker安装 警告切勿在没有配置 Docker APT 源的情况下直接使用 apt 命令安装 Docker. 安装环境
OSUbuntu 18.04 64 bit
显卡NVidia GTX 2080 Ti x 2
CUDA10.0
cnDNN7.4准备工作
系统要求
Docker CE 支持以下版本的 Ubuntu 操作系统
Bionic 18.04 (LTS)Xenial 16.04 (LTS)Trusty 14.04 (LTS) (Docker CE v18.06 及以下版本)
Docker CE 可以安装在 64 位的 x86 平台或 ARM 平台上。Ubuntu 发行版中LTSLong-Term-Support长期支持版本会获得 5 年的升级维护支持这样的版本会更稳定因此在生产环境中推荐使用 LTS 版本。
卸载旧版本
旧版本的 Docker 称为 docker 或者 docker-engine使用以下命令卸载旧版本
$ sudo apt-get remove docker \docker-engine \docker.ioUbuntu 14.04 可选内核模块
从 Ubuntu 14.04 开始一部分内核模块移到了可选内核模块包 (linux-image-extra-*) 以减少内核软件包的体积。正常安装的系统应该会包含可选内核模块包而一些裁剪后的系统可能会将其精简掉。AUFS 内核驱动属于可选内核模块的一部分作为推荐的 Docker 存储层驱动一般建议安装可选内核模块包以使用 AUFS。
如果系统没有安装可选内核模块的话可以执行下面的命令来安装可选内核模块包
$ sudo apt-get update
$ sudo apt-get install \linux-image-extra-$(uname -r) \linux-image-extra-virtualUbuntu 16.04
Ubuntu 16.04 上的 Docker CE 默认使用 overlay2 存储层驱动,无需手动配置。
使用 APT 安装
由于 apt 源使用 HTTPS 以确保软件下载过程中不被篡改。因此我们首先需要添加使用 HTTPS 传输的软件包以及 CA 证书。
$ sudo apt-get update
$ sudo apt-get install \apt-transport-https \ca-certificates \curl \software-properties-common鉴于国内网络问题强烈建议使用国内源官方源请在注释中查看。
为了确认所下载软件包的合法性需要添加软件源的 GPG 密钥。
$ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# 官方源
# $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -然后我们需要向 source.list 中添加 Docker 软件源
$ sudo add-apt-repository \deb [archamd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \$(lsb_release -cs) \stable
# 官方源
# $ sudo add-apt-repository \
# deb [archamd64] https://download.docker.com/linux/ubuntu \
# $(lsb_release -cs) \
# stable以上命令会添加稳定版本的 Docker CE APT 镜像源如果需要测试或每日构建版本的 Docker CE 请将 stable 改为 test 或者 nightly。 安装 Docker CE
更新 apt 软件包缓存并安装 docker-ce
$ sudo apt-get update
$ sudo apt-get install docker-ce使用脚本自动安装
在测试或开发环境中 Docker 官方为了简化安装流程提供了一套便捷的安装脚本Ubuntu 系统上可以使用这套脚本安装
$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun执行这个命令后脚本就会自动的将一切准备工作做好并且把 Docker CE 的 Edge 版本安装在系统中。
启动 Docker CE
$ sudo systemctl enable docker
$ sudo systemctl start dockerUbuntu 14.04 请使用以下命令启动
$ sudo service docker start建立 docker 用户组
默认情况下docker 命令会使用 Unix socket 与 Docker 引擎通讯。而只有 root 用户和 docker 组的用户才可以访问 Docker 引擎的 Unix socket。出于安全考虑一般 Linux 系统上不会直接使用 root 用户。因此更好地做法是将需要使用 docker 的用户加入 docker 用户组。
建立 docker 组
$ sudo groupadd docker将当前用户加入 docker 组
$ sudo usermod -aG docker $USER退出当前终端并重新登录进行如下测试。
测试 Docker 是否安装正确
$ docker run hello-world
Unable to find image hello-world:latest locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Status: Downloaded newer image for hello-world:latest
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 theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto 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/若能正常输出以上信息则说明安装成功。
镜像加速
如果在使用过程中发现拉取 Docker 镜像十分缓慢可以配置 Docker 国内镜像加速。
Docker使用
拉取镜像
docker pull nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04创建容器
docker creat --name myDocker --gpus all -it --shm-size1gb -v /home/andy/DevWorkSpace:~/DevWorkSpace nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04 /bin/bash查看本地镜像
docker images删除镜像
docker rmi nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04运行容器
docker exec -it myDocker /bin/bash查看容器运行情况
docker ps # 查看运行中的容器
docker ps -a # 查看所有容器停止容器
docker stop myDocker销毁容器
docker rm myDockerdocker中常见的错误
bash: nvcc: command not found To get access to the CUDA development tools, you should use the devel images instead. These are the relevant tags:nvidia/cuda:10.2-devel-ubuntu18.04
nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04These would then give you access to the tools such as nvcc and the cuDNN header files that are required for development.
参考文档 Docker — 从入门到实践 Docker 官方 Ubuntu 安装文档