ubuntu16.04安装Docker-华为荣耀MagicBook Pro

更新包索引

sudo apt-get update

安装一些包使apt能够通过HTTPS使用repository

sudo apt-get install  apt-transport-https ca-certificates curl gnupg-agent software-properties-common

添加Docker官方GPG key

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

通过搜索指纹的后8个字符,验证您现在是否拥有带有指纹的密钥9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88

sudo apt-key fingerprint 0EBFCD88

输出内容是:

pub   4096R/0EBFCD88 2017-02-22
      Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid                  Docker Release (CE deb) <docker@docker.com>
sub   4096R/F273FCD8 2017-02-22

设置stable版本的repository

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

安装stable版本

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

验证安装结果

sudo docker run hello-world

输出内容为:


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://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

表明安装成功。

下面是一些使用操作。

解决每次使用Docker需要使用sudo的问题

方法是创建一个docker组并把你的用户加进去

创建docker用户组

sudo groupadd docker

把你的用户加到docker组里面

sudo usermod -aG docker $USER

登出再登陆,使用这些设置起效

验证可以不用sudo来运行docker

docker run hello-world
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容