Docker 是一个开源的应用容器引擎,可以让开发者打包他们的应用以及应用的依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。以下是 Docker 在 Ubuntu 上的安装指南。
安装 Docker
1. 更新 apt 包索引
sudo apt-get update
2. 安装软件包
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
3. 添加 Docker 官方 GPG 密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
4. 设置 Docker 仓库
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
5. 安装 Docker
sudo apt-get update
sudo apt-get install docker-ce
验证安装
安装完成后,您可以运行以下命令来验证 Docker 是否已正确安装:
sudo docker --version
或者
docker run hello-world
如果一切正常,您将看到如下输出:
Hello from Docker!
This message shows that your installation appears to be working correctly.
To verify that Docker is correctly installed, you can try running the hello-world image with the following command:
docker run hello-world
To run a sample web application, try the following:
docker run -d -p 8080:80 nginx
获取更多帮助
如果您需要更多帮助,请访问 Docker 官方文档。
Docker Logo