docker安装

一、Docker介绍与安装

安装

官方安装文档

ubuntu下安装

如果是第一次安装,你需要先添加docker的源然后再安装

  1. 更新包

    sudo apt-get update
  2.  安装证书

    

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

  3. 添加docker的官方GPGkey  

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

  4. 添加docker源

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

 

安装 docker ce

  1. 更新包索引

  sudo apt-get update

  2. 安装docker

  sudo apt-get install docker-ce

  3. 检测是否安装成功

  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/

为了方便使用,不用sudo就可以运行docker命令,安装好docker后再命令行输入如下命令:

sudo usermod -aG docker $USER

 如果是xshell执行此命令,则需要断开xshell连接,重新进入

原文地址:https://www.cnblogs.com/zhanghaibin16/p/12272333.html