ubuntu22.04安装docker安装Docker 命令补全工具
时间: 2024-10-25 12:08:48 浏览: 19
Linux环境下ubuntu22.04安装Docker到配置Homeassistant
在Ubuntu 22.04上安装Docker并配置命令补全工具,通常可以按照以下步骤操作:
1. **更新系统**:
```sh
sudo apt update
```
2. **安装依赖**:
对于一些库的支持,需要先安装`apt-transport-https ca-certificates curl gnupg lsb-release
```
3. **添加Docker GPG钥**:
```sh
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
```
4. **将Docker仓库添加到Apt源**:
```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
```
5. **更新软件包列表**:
```sh
sudo apt-get update
```
6. **安装Docker CE**(Community Edition):
```sh
sudo apt install docker-ce docker-ce-cli containerd.io
```
7. **启动并启用Docker服务**:
```sh
sudo systemctl start docker
sudo systemctl enable docker
```
8. **安装命令补全工具**(例如`oh-my-zsh`或`zsh-completions-docker`):
如果使用ZSH,可以在终端运行:
```sh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/main/install.sh)"
brew install zsh
git clone https://github.com/zsh-users/zsh-completions ~/.zcompdump
```
或者其他你喜欢的命令行提示符插件。
9. **验证Docker是否安装成功**:
```sh
docker run hello-world
```
阅读全文