安装Docker CE:
- 卸载老版本的Docker:如果已经安装了旧版本的Docker,可以通过以下命令卸载:
sudo apt-get remove docker docker-engine docker.io containerd runc
- 安装必要的依赖:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
- 添加Docker的GPG秘钥:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- 添加Docker的APT源:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- 安装Docker CE:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
- 验证Docker是否安装成功:
sudo docker run hello-world
如果输出以下信息,说明安装成功:
Hello from Docker!
This message shows that your installation appears to be working correctly.
安装Docker Compose:
- 下载Docker Compose二进制文件:
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- 赋予执行权限:
sudo chmod +x /usr/local/bin/docker-compose
- 验证Docker Compose是否安装成功:
docker-compose --version
如果输出Docker Compose的版本信息,说明安装成功:
docker-compose version 1.29.2, build 5becea4c