Blogger Information
Blog 11
fans 0
comment 1
visits 13882
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Ubuntu16.04 安装 Docker
Alfred的学习笔记
Original
1459 people have browsed it

亲测可用

1.先换源

  1. vi /etc/apt/sources.list

更新成下面的源地址

腾讯源
  1. deb http://mirrors.tencentyun.com/ubuntu/ xenial main restricted universe multiverse
  2. deb http://mirrors.tencentyun.com/ubuntu/ xenial-security main restricted universe multiverse
  3. deb http://mirrors.tencentyun.com/ubuntu/ xenial-updates main restricted universe multiverse
  4. deb-src http://mirrors.tencentyun.com/ubuntu/ xenial main restricted universe multiverse
  5. deb-src http://mirrors.tencentyun.com/ubuntu/ xenial-security main restricted universe multiverse
  6. deb-src http://mirrors.tencentyun.com/ubuntu/ xenial-updates main restricted universe multiverse
阿里源
  1. # deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
  2. deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
  3. deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
  4. deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
  5. deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
  6. deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
  7. deb http://mirrors.aliyun.com/ubuntu/ xenial universe
  8. deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
  9. deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
  10. deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
  11. deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
  12. deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
  13. deb http://archive.canonical.com/ubuntu xenial partner
  14. deb-src http://archive.canonical.com/ubuntu xenial partner
  15. deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
  16. deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
  17. deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
  18. deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

2.更新源

  1. apt-get update

3.允许apt通过https使用仓库

  1. sudo dpkg --configure -a
  2. sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

4.添加Docker官方GPG key

  1. #官方的
  2. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  3. #阿里的
  4. curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

5.设置Docker稳定版仓库

  1. #官方的
  2. sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  3. #阿里的
  4. sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

6.更新apt源索引

  1. sudo apt-get update

7.安装最新版本Docker CE(社区版)

  1. sudo apt-get install docker-ce

8.查看Docker版本

  1. docker --version

9.检查Docker CE是否安装正确

  1. sudo docker run hello-world

如果Docker下载程序镜像慢

  1. vi /etc/docker/daemon.json
  2. #填写以下内容,换阿里的镜像源
  3. {
  4. "registry-mirrors":["https://izbm3lvv.mirror.aliyuncs.com"]
  5. }

基本命令

  1. # 启动docker
  2. sudo service docker start
  3. # 停止docker
  4. sudo service docker stop
  5. # 重启docker
  6. sudo service docker restart
  7. # 列出镜像
  8. docker image ls
  9. # 拉取镜像
  10. docker image pull library/hello-world
  11. # 删除镜像
  12. docker image rm 镜像id/镜像ID
  13. # 创建容器
  14. docker run [选项参数] 镜像名 [命令]
  15. # 停止一个已经在运行的容器
  16. docker container stop 容器名或容器id
  17. # 启动一个已经停止的容器
  18. docker container start 容器名或容器id
  19. # kill掉一个已经在运行的容器
  20. docker container kill 容器名或容器id
  21. # 删除容器
  22. docker container rm 容器名或容器id
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post