1 - 安装概述

Docker安装概述

Docker 目前分为 Community Edition (CE) 和 Enterprise Edition (EE) 两个版本。日常学习开发考虑使用CE版本。

而 Docker Community Edition (CE) 又分为 Stable / Test / Nightly 三个版本,如果不需要最新的特性,那么 Stable 是比较合适的选择。

以下安装都是选择 Docker Community Edition Stable 版本, 参考docker官网的文章:

https://docs.docker.com/install/

2 - Ubuntu下安装Docker

Docker在Ubuntu20.04/22.04/23.04下的安装

参考官网文档:

https://docs.docker.com/install/linux/docker-ce/ubuntu/

适用于以下版本:

  • Ubuntu Lunar 23.04
  • Ubuntu Kinetic 22.10
  • Ubuntu Jammy 22.04 (LTS)
  • Ubuntu Focal 20.04 (LTS)

准备工作

清除老版本:

for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done

安装需要的工具:

sudo apt-get update
sudo apt-get install ca-certificates curl gnupg

添加 GPG key:

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

准备用于 apt 的仓库:

echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

此时打开 /etc/apt/sources.list.d/docker.list 文件:

sudo vi /etc/apt/sources.list.d/docker.list

就能看到如下内容:

deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu   jammy stable

其中 jammy 是ubuntu版本代码名称 VERSION_CODENAME ,其内容来自文件 /etc/os-release:

PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

执行 apt update 之后:

sudo apt-get update

就可以安装了。

安装

一般 不推荐 安装最新版本,尤其是和 k8s 一起使用时:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

可以先执行

apt-cache madison docker-ce
# apt-cache madison docker-ce | awk '{ print $3 }'

查看当前可选版本:

 docker-ce | 5:24.0.2-1~ubuntu.22.04~jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:24.0.1-1~ubuntu.22.04~jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:24.0.0-1~ubuntu.22.04~jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:23.0.6-1~ubuntu.22.04~jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:23.0.5-1~ubuntu.22.04~jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:23.0.4-1~ubuntu.22.04~jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:23.0.3-1~ubuntu.22.04~jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:23.0.2-1~ubuntu.22.04~jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:23.0.1-1~ubuntu.22.04~jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:23.0.0-1~ubuntu.22.04~jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:20.10.24~3-0~ubuntu-jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:20.10.23~3-0~ubuntu-jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:20.10.22~3-0~ubuntu-jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:20.10.21~3-0~ubuntu-jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:20.10.20~3-0~ubuntu-jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:20.10.19~3-0~ubuntu-jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:20.10.18~3-0~ubuntu-jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:20.10.17~3-0~ubuntu-jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:20.10.16~3-0~ubuntu-jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:20.10.15~3-0~ubuntu-jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:20.10.14~3-0~ubuntu-jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:20.10.13~3-0~ubuntu-jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages

这里先固定使用 20.10.21 版本, 执行安装命令:

VERSION_STRING=5:20.10.21~3-0~ubuntu-jammy
sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin

安装完成后检验一下:

sudo docker run hello-world

查看安装的版本:

$ docker --version
Docker version 20.10.21, build baeda1f

设置

设置权限避免每次sudo

为了以非 root 用户使用 docker, 可以将用户加入 “docker” 组.

sudo usermod -aG docker sky

重新登录之后生效。验证一下:

docker run hello-world

取消 apt source 更新

docker 安装之后,没有必要时刻保持更新,因此可以取消 apt source的设置,加速 apt update 的执行:

sudo vi /etc/apt/sources.list.d/docker.list

将内容注释即可。

修改 containerd 的配置

containerd 的默认配置文件中 disable 了 CRI ,可以打开文件 /etc/containerd/config.toml 看到这行:

disabled_plugins = ["cri"]

将这行注释之后,重启 containerd:

sudo systemctl restart containerd.service

如果不做这个修改,k8s 安装时会报错 “CRI v1 runtime API is not implemented”。

3 - Macos下安装Docker

Docker在MacOS下的安装

参考:

下载

m1安装

对于 m1 芯片的用户,先安装 rosetta 2:

softwareupdate –install-rosetta

正常安装,过程简单。

验证一下安装,看一下版本信息:

$ docker version                                     
Client:
 Cloud integration: v1.0.22
 Version:           20.10.12
 API version:       1.41
 Go version:        go1.16.12
 Git commit:        e91ed57
 Built:             Mon Dec 13 11:46:56 2021
 OS/Arch:           darwin/arm64
 Context:           default
 Experimental:      true

Server: Docker Desktop 4.5.0 (74594)
 Engine:
  Version:          20.10.12
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.12
  Git commit:       459d0df
  Built:            Mon Dec 13 11:43:07 2021
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

验证一下:

  sudo docker run hello-world

输出如下:

docker run hello-world 
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
93288797bd35: Pull complete 
Digest: sha256:4c5f3db4f8a54eb1e017c385f683a2de6e06f75be442dc32698c9bbe6c861edd
Status: Downloaded newer image for hello-world:latest

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.
    (arm64v8)
 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/

intel芯片安装

TBD:准备放弃黑苹果,专心用m1。

4 - Docker安装后的设置

Docker安装后的设置

镜像加速

为了加速拉取 Docker ,需要配置镜像地址:

mac下修改

任务栏点击 Docker for mac 应用图标 -> Perferences… -> Daemon -> Registry mirrors。

linux下修改

针对Docker客户端版本大于 1.10.0 的用户

通过修改daemon配置文件/etc/docker/daemon.json来使用加速器

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://****.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

参考文章:

5 - [归档]ubuntu 16.04下安装Docker

Docker在Linux下的安装

归档原因:不再使用ubuntu 16.04.

以 ubuntu 为例,参考官网文档:

https://docs.docker.com/install/linux/docker-ce/ubuntu/

安装准备

看一下自己的Linux机器版本和内核信息:

  • uname --all

    Linux skywork 4.15.0-38-generic #41~16.04.1-Ubuntu SMP Wed Oct 10 20:16:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
    
    
    
  • cat /proc/version

    Linux version 4.15.0-38-generic (buildd@lcy01-amd64-023) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10)) #41~16.04.1-Ubuntu SMP Wed Oct 10 20:16:04 UTC 2018
    
    
    
  • lsb_release -a

    No LSB modules are available.
    Distributor ID:	LinuxMint
    Description:	Linux Mint 18.3 Sylvia
    Release:	18.3
    Codename:	sylvia
    
    
    

这台机器是Linux Mint 18.3 升级到非常新的Linux内核4.15.0-38了,Linux Mint 18.3 是基于 Ubuntu 16.04,但是有些系统参数不一样,比如这里 Codename 是 sylvia,而不是 Ubuntu 16.04 的 xenial。后面安装时要小心,需要修改为 Ubuntu 16.04 的参数。

安装步骤

  1. 卸载旧版本

    sudo apt-get remove docker docker-engine docker.io
    
  2. 安装docker

    简单起见,使用 docker 仓库安装。

    sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    # 官方给的是这样,但是`lsb_release -cs`在Linux Mint下取值会不对,因此手工修改
    # Linux Mint 18是基于ubuntu 16.04,为 xenial
    # Linux Mint 19是基于ubuntu 18.04,为 bionic
    # sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    # for ubuntu 16.04 / linuxmint 18.*
    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
    # for ubuntu 18.04 / linuxmint 19.*
    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
    sudo apt-get update
    sudo apt-get install docker-ce
    

    如果不想安装最新版本,则可以先查看当前可选版本:

    $ apt-cache madison docker-ce
     docker-ce | 5:18.09.2~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
     docker-ce | 5:18.09.1~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
     docker-ce | 5:18.09.0~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
     docker-ce | 18.06.2~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
     docker-ce | 18.06.1~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
     docker-ce | 18.06.0~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
     docker-ce | 18.03.1~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
    

    然后执行 :

        sudo apt-get install docker-ce=18.06.2~ce~3-0~ubuntu
    

    ``

  3. 验证安装

    安装完成之后,看一下版本信息:

    $ docker version
    Client:
    Version:           18.06.1-ce
    API version:       1.38
    Go version:        go1.10.3
    Git commit:        e68fc7a
    Built:             Tue Aug 21 17:24:56 2018
    OS/Arch:           linux/amd64
    Experimental:      false
    
    Server:
    Engine:
    Version:          18.06.1-ce
    API version:      1.38 (minimum version 1.12)
    Go version:       go1.10.3
    Git commit:       e68fc7a
    Built:            Tue Aug 21 17:23:21 2018
    OS/Arch:          linux/amd64
    Experimental:     false
    
    

    验证一下:

    sudo docker run hello-world
    

    输出如下:

    $ sudo docker run hello-world
    Unable to find image 'hello-world:latest' locally
    
    latest: Pulling from library/hello-world
    78445dd45222: Pull complete
    Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
    Status: Downloaded newer image for hello-world:latest
    
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    ...
    
  4. 设置权限避免每次sudo

    为了以非root用户使用docker, 可以将用户加入"docker"组.

    sudo usermod -aG docker sky
    

    重新登录之后生效。

  5. 安装 docker client

    从下列地址下载到对应的 docker client 安装包:

    https://mirrors.ustc.edu.cn/docker-ce/linux/static/stable/x86_64/

    tar -zxvf docker-18.09.2.tgz
    cd docker
    sudo cp * /usr/local/bin/
    

    ``

6 - [归档]Ubuntu20.04下安装Docker

Docker在Ubuntu20.04下的安装

以 ubuntu 20.04(也包括作为桌面使用的 Linux Mint 21) 为例,参考官网文档:

https://docs.docker.com/install/linux/docker-ce/ubuntu/

安装准备

看一下自己的Linux机器版本和内核信息:

  • uname --all

    Linux skywork 5.15.0-53-generic #59-Ubuntu SMP Mon Oct 17 18:53:30 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
    
    
    
  • cat /proc/version

    Linux version 5.15.0-53-generic (buildd@lcy02-amd64-047) (gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #59-Ubuntu SMP Mon Oct 17 18:53:30 UTC 2022
    
  • lsb_release -a

    No LSB modules are available.
    Distributor ID:	Linuxmint
    Description:	Linux Mint 21
    Release:	21
    Codename:	vanessa
    
    
    

这台机器是Linux Mint 21 升级到非常新的Linux内核5.15.0-53了,Linux Mint 21 是基于 Ubuntu 20.04,但是有些系统参数不一样,比如这里 Codename 是 vanessa,而不是 Ubuntu 20.04 的 Focal Fossa。后面安装时要小心,需要修改为 Ubuntu 20.04 的参数。

ubuntu各个版本的codename 请见:https://download.docker.com/linux/ubuntu/dists/

安装步骤

卸载旧版本

sudo apt-get remove docker docker-engine docker.io containerd runc

安装docker

简单起见,使用 docker 仓库安装。

$ sudo apt-get install ca-certificates curl gnupg lsb-release

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

# 官方给的是这样,
# echo \
#  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \
# https://download.docker.com/linux/ubuntu \
#  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# 但是`lsb_release -cs`在Linux Mint下取值会不对,因此手工修改
# for ubuntu 20.04 / linuxmint 20.02,$(lsb_release -cs)替代为 focal
$ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

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

如果不想安装最新版本,则可以先查看当前可选版本:

$ apt-cache madison docker-ce
docker-ce | 5:20.10.21~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.20~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.19~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.18~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.17~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.16~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.15~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.14~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.13~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.12~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.11~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.10~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.9~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.8~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.7~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.6~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.5~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.4~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.3~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.2~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.1~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.0~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.15~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.14~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.13~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.12~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.11~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.10~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.9~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages

然后执行 :

sudo apt-get install docker-ce=20.10.21~3-0~ubuntu

验证安装

安装完成之后,看一下版本信息:

$ docker --version
Docker version 20.10.21, build baeda1f

验证一下:

sudo docker run hello-world

输出如下:

$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally

latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:faa03e786c97f07ef34423fccceeec2398ec8a5759259f94d99078f264e9d7af
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.
...

设置权限避免每次sudo

为了以非root用户使用docker, 可以将用户加入"docker"组.

sudo usermod -aG docker sky

重新登录之后生效。

设置docker的cgroup driver

备注: 发现 docker 20.10.21~3-0~ubuntu 版本已经修改为默认 systemd ,因此新版本可以不用这么设置。

docker 默认的 cgroup driver 是 cgroupfs,可以通过 docker info 命令查看:

$ docker info | grep "Cgroup Driver"
Cgroup Driver: cgroupfs

而 kubernetes 在v1.22版本之后,如果用户没有在 KubeletConfiguration 下设置 cgroupDriver 字段,则 kubeadm 将默认为 systemd

为了保持一致,需要修改 docker 的 cgroup driver 为 systemd, 方式为打开 docker 的配置文件(如果不存在则创建)

sudo vi /etc/docker/daemon.json

增加内容:

{
	"exec-opts": ["native.cgroupdriver=systemd"]
}

修改完成后重启 docker:

sudo systemctl restart docker

# 重启后检查一下
docker info | grep "Cgroup Driver"

设置swap limit

如果遇到如下的 “No swap limit support” 警告:

docker info | grep "Cgroup Driver"
 Cgroup Driver: systemd
WARNING: No swap limit support

则说明 swap limit 功能没能开启。解决方法是 grub

$ sudo vi /etc/default/grub
......
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
......

执行下面命令生效并重启。

$ sudo update-grub2
$ sudo reboot

参考资料: