環境
- debian 9 Stretch
安裝 docker
docker-ce 即 DOCKER ENGINE - COMMUNITY
卸載舊版本
目前我沒遇到,但是還是卸載一下比較好
sudo apt-get remove docker docker-engine docker.io containerd runc
更新現有的包列表
sudo apt-get update
安裝軟件包以允許apt通過HTTPS使用存儲庫
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
添加Docker的官方GPG密鑰
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
驗證是否擁有帶有指紋的密鑰(可選)
sudo apt-key fingerprint 0EBFCD88
顯示
pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) <[email protected]>
sub rsa4096 2017-02-22 [S]
與指紋的後8個字符9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
相同
將Docker存儲庫添加到APT源
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
安裝最新版 docker-ce
使用新添加的repo中的Docker包更新包數據庫
sudo apt-get update
安裝最新版 docker-ce
sudo apt-get install docker-ce
安裝指定版本 docker-ce
使用新添加的repo中的Docker包更新包數據庫
sudo apt-get update
列出適配當前系統的 docker-ce 版本
apt-cache madison docker-ce
顯示
docker-ce | 5:19.03.7~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages
docker-ce | 5:19.03.6~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages
docker-ce | 5:19.03.5~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages
...
安裝指定版本 docker-ce
sudo apt-get install docker-ce=<VERSION_STRING>
<VERSION_STRING>
即 5:19.03.7~3-0~debian-stretch
安裝 docker-compose
獲取
Compose repository release page on GitHub
安裝
curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
增加可執行權限
chmod +x /usr/local/bin/docker-compose
參考
問題解決
docker info 提示 WARNING: No swap limit support
Docker可以通過啓動命令來限制容器可以使用的最大物理內存和swap,但是通常在使用這些命令的時候經常會碰到“WARNING: No swap limit support”警告,大概意思就是不支持swap內存的限制。
- 打開文件
vi /etc/default/grub
- 追加內容
在GRUB_CMDLINE_LINUX
的內容後進行追加,原內容不要改動
cgroup_enable=memory swapaccount=1
添加之前要加上空格,使其和前面的內容分開
# This file was created by bootstrap-vz.
# See https://github.com/andsens/bootstrap-vz/blob/master/LICENSE for
# legal notices and disclaimers.
GRUB_TERMINAL="console"
GRUB_CMDLINE_LINUX="console=ttyS0,38400n8 elevator=noop scsi_mod.use_blk_mq=Y net.ifnames=0 biosdevname=0 cgroup_enable=memory swapaccount=1"
GRUB_TIMEOUT=0
GRUB_SERIAL_COMMAND="serial"
GRUB_DISABLE_RECOVERY=True
GRUB_GFXMODE="auto"
GRUB_HIDDEN_TIMEOUT_QUIET=True
GRUB_HIDDEN_TIMEOUT=0
GRUB_DEFAULT=0
- 保存升級
sudo update-grub
- 重啓服務器
reboot