ubuntu24.04安装docker
时间: 2024-06-09 20:03:53 浏览: 336
Ubuntu 24.04(代号“Focal Fossa”)是一个长期支持版本的Linux发行版,安装Docker在新版本的系统中相对简单,因为它已经包含了官方的包。以下是安装Docker on Ubuntu 24.04的基本步骤:
1. **更新系统和添加apt源**:
```sh
sudo apt update && sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
```
2. **添加Docker GPG密钥**:
```sh
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
```
3. **添加Docker仓库**:
```sh
echo "deb [arch=amd64 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
```
4. **刷新并安装Docker**:
```sh
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
```
5. **启动并启用Docker服务**:
```sh
sudo systemctl start docker
sudo systemctl enable docker
```
6. **验证Docker是否安装成功**:
```sh
sudo docker run hello-world
```
7. **登录到Docker Hub** (如果需要):
```sh
sudo usermod -aG docker $USER
logout
login
```
阅读全文