1. Linux 安装docker

    1. 首先我们创建一个目录赋予权限并进入该目录

      vagrant@ubuntu-xenial:~$ sudo mkdir  -m 775 -vp  /data/www  && cd /data/www
       mkdir: created directory '/data'
       mkdir: created directory '/data/www'
    2. 安装docker本身

      sudo wget -qO- https://get.docker.com | sh
      或者
      curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
      也可以使用国内 daocloud 一键安装命令:
      curl -sSL https://get.daocloud.io/docker | sh

      解释一下命令的意思:

      sudo:_当前命令我希望用root用户执行_

      wget:_是命令行的一个下载工具_

      -qO-:_让wget标准输出_

      | sh :_交给shell去执行_

      总的连起来:_以root用户身份用wget下载工具下载一个shell脚本文件标准输出交给sh执行_

      vagrant@ubuntu-xenial:/data/www$ sudo wget -qO- https://get.docker.com | sh
      # Executing docker install script, commit: 26ff363bcf3b3f5a00498ac43694bf1c7d9ce16c
      + sudo -E sh -c apt-get update -qq >/dev/null
      + sudo -E sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
      + sudo -E sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | apt-key add -qq - >/dev/null
      + sudo -E sh -c echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable" > /etc/apt/sources.list.d/docker.list
      + sudo -E sh -c apt-get update -qq >/dev/null
      + [ -n  ]
      + sudo -E sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/null
      + sudo -E sh -c docker version
      Client: Docker Engine - Community
       Version:           19.03.12
       API version:       1.40
       Go version:        go1.13.10
       Git commit:        48a66213fe
       Built:             Mon Jun 22 15:45:49 2020
       OS/Arch:           linux/amd64
       Experimental:      false
      
      Server: Docker Engine - Community
       Engine:
        Version:          19.03.12
        API version:      1.40 (minimum version 1.12)
        Go version:       go1.13.10
        Git commit:       48a66213fe
        Built:            Mon Jun 22 15:44:20 2020
        OS/Arch:          linux/amd64
        Experimental:     false
       containerd:
        Version:          1.2.13
        GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
       runc:
        Version:          1.0.0-rc10
        GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
       docker-init:
        Version:          0.18.0
        GitCommit:        fec3683
      If you would like to use Docker as a non-root user, you should now consider
      adding your user to the "docker" group with something like:
      
        sudo usermod -aG docker vagrant
      
      Remember that you will have to log out and back in for this to take effect!
      
      WARNING: Adding a user to the "docker" group will grant the ability to run
               containers which can be used to obtain root privileges on the
               docker host.
               Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
               for more information.
      
      
    3. 允许非root用户运行docker

      vagrant@ubuntu-xenial:/data/www$ sudo usermod -aG docker vagrant  #修改用户组,把当前用户加到docker组里 
      vagrant@ubuntu-xenial:/data/www$ newgrp docker                    # 切换用户组
    4. 测试是否成功

      vagrant@ubuntu-xenial:/data/www$ docker info  # 测试是否可以打印出docker信息
      Client:
       Debug Mode: false
      
      Server:
       Containers: 0
        Running: 0
        Paused: 0
        Stopped: 0
       Images: 0
       Server Version: 19.03.12
       Storage Driver: overlay2
        Backing Filesystem: extfs
        Supports d_type: true
        Native Overlay Diff: true
       Logging Driver: json-file
       Cgroup Driver: cgroupfs
       Plugins:
        Volume: local
        Network: bridge host ipvlan macvlan null overlay
        Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
       Swarm: inactive
       Runtimes: runc
       Default Runtime: runc
       Init Binary: docker-init
       containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
       runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
       init version: fec3683
       Security Options:
        apparmor
        seccomp
         Profile: default
       Kernel Version: 4.4.0-161-generic
       Operating System: Ubuntu 16.04.6 LTS
       OSType: linux
       Architecture: x86_64
       CPUs: 2
       Total Memory: 991.9MiB
       Name: ubuntu-xenial
       ID: G2VB:OFWI:G55A:SZLO:QZMV:O4UX:XKJT:ANWD:3VDI:4JET:G5SM:NNYE
       Docker Root Dir: /var/lib/docker
       Debug Mode: false
       Registry: https://index.docker.io/v1/
       Labels:
       Experimental: false
       Insecure Registries:
        127.0.0.0/8
       Live Restore Enabled: false
      
      WARNING: No swap limit support
Last modification:October 12, 2020
如果觉得我的文章对你有用,请随意赞赏