云服务器系统环境: 华为云 Ubuntu 9.3.0-17ubuntu1~20.04
1.ECS准备docker相关环境
1.1ECS安装docker
一行一行执行 都是从官网找的命令
sudo -i
apt update
apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
– 安装最新版
apt update
apt install docker-ce docker-ce-cli containerd.io
systemctl status docker
锁住当前版本
apt-mark hold docker-ce
修改2375端口 防止被攻击
vim /usr/lib/systemd/system/docker.service
加上
-H tcp://0.0.0.0:4566
保存
systemctl daemon-reload
systemctl restart docker
systemctl status docker
测试
curl http://localhost:4566/version
修改docker镜像源
vi /etc/docker/daemon.json
复制上
{
"registry-mirrors": ["http://hub-mirror.c.163.com","https://registry.docker-cn.com"]
}
配置完毕重启下docker服务
systemctl daemon-reload
systemctl restart docker
1.2安装docker-compose
这一步超级慢 我是没什么办法,服务器翻墙 手工下载传上去 我试了 都不行
curl -L "https://github.com/docker/compose/releases/download/v2.10.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose