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





      | sh :_交给shell去执行_


      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
        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
        Version:          1.2.13
        GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
        Version:          1.0.0-rc10
        GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
        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信息
      Debug Mode: false
      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
       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:
        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
      Docker Root Dir: /var/lib/docker
      Debug Mode: false
      Registry: https://index.docker.io/v1/
      Experimental: false
      Insecure Registries:
      Live Restore Enabled: false
      WARNING: No swap limit support


Last modification:October 12th, 2020 at 10:00 am