码迷,mamicode.com
首页 > 系统相关 > 详细

Ubuntu 16.04安装Docker步骤

时间:2018-06-02 13:26:34      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:als   地址   lin   digest   targe   fss   sys   apt   inux   

(本文翻译自https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04)

 

添加GPG Key:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

 

添加apt-get源

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

 

刷新apt

$ sudo apt-get update

 

查看apt对docker的下载地址,确保不是原来ubuntu的旧地址:

$ apt-cache policy docker-ce
docker-ce:
  Installed: (none)
  Candidate: 17.03.1~ce-0~ubuntu-xenial
  Version table:
     17.03.1~ce-0~ubuntu-xenial 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     17.03.0~ce-0~ubuntu-xenial 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages

 

安装docker:

$ sudo apt-get install -y docker-ce

 

启动docker:

$ sudo systemctl status docker

 

检查docker运行状态:

$ sudo systemctl status docker
docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2016-05-01 06:53:52 CDT; 1 weeks 3 days ago
     Docs: https://docs.docker.com
 Main PID: 749 (docker)

 

一般来说,安装后的docker需要sudo来运行:

$ docker ps
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.37/containers/json: dial unix /var/run/docker.sock: connect: permission denied

 

执行以下步骤,此后就不需要sudo了。

首先,将你自己加入docker组:

$ sudo usermod -aG docker ${USER}

 

然后,令改动生效:

$ su - ${USER}

 

你也可以将其他人加入docker组:

$ sudo usermod -aG docker username

 

跑个Hello World试试:

$ docker run hello-world
Unable to find image hello-world:latest locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete 
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
Status: Downloaded newer image for hello-world:latest

Hello from Docker!

 

大功告成!

 

Ubuntu 16.04安装Docker步骤

标签:als   地址   lin   digest   targe   fss   sys   apt   inux   

原文地址:https://www.cnblogs.com/JansenGao/p/how-to-install-docker-on-ubuntu-16-04.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!