ubuntu-docker安装

系统信息

  • ubuntu-17.10-desktop-amd64

旧版本卸载

    sudo apt-get remove docker docker-engine docker.io

更新软件依赖

apt-get update

安装软件包

apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

添加GPG密钥

推荐使用国内安装源(下述安装源均为中国科技大学开源软件镜像地址 https://mirrors.ustc.edu.cn

curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

设置镜像源

  sudo add-apt-repository \
  "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
  $(lsb_release -cs) \
  stable"

更新软件包

sudo apt-get update

安装docker

个人安装版本为docker ce,企业级安装为docker ee
下面为个人安装版本

sudo apt-get install docker-ce

以上安装的是docker最新版本,如果需要安装指定版本

  1. 命令查询相关版本
sudo apt-cache madison docker-ce
  1. 通过版本号进行安装(以17.09.1~ce-0~ubuntu为例)
sudo apt-get install docker-ce=17.09.1~ce-0~ubuntu

运行hello-world镜像

docker run hello-world

运行结果:

Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:445b2fe9afea8b4aa0b2f27fe49dd6ad130dfe7a8fd0832be5de99625dad47cd
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 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://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/

查看本机docker容器信息

docker container ls -a

运行结果为
这里写图片描述

通过docker用户管理docker

  • 创建用户组
sudo groupadd docker
  • 添加docker用户
sudo usermod -aG docker $USER
  • 注销系统重新登录
  • 运行镜像 (不再需要sudo)
docker run hello-world

卸载docker-ce

  • 卸载
sudo apt-get purge docker-ce
  • 删除所有镜像、容器、
sudo rm -rf /var/lib/docker
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值