---
# System prepended metadata

title: 安裝Docker CE+Docker-compose在 Debian 10/Debian 11上
tags: [docker]

---

###### tags: `docker`

# 安裝Docker CE+Docker-compose在 Debian 10/Debian 11上

- CE: Community Edition

1. 安裝依賴
```shell
sudo apt update
sudo apt -y install apt-transport-https ca-certificates curl gnupg2 software-properties-common
```
2. 加入Docker官方的GPG key
```shell
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker-archive-keyring.gpg
```
3. 下載Docker CE的repository
```shell
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/debian \
   $(lsb_release -cs) \
   stable"
```
4. 安裝Docker CE與docker-compose
```shell
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io -y
#啟動docker
sudo systemctl enable --now docker
#安裝docker-compose
sudo apt install -y curl wget
curl -s https://api.github.com/repos/docker/compose/releases/latest | grep browser_download_url  | grep docker-compose-linux-x86_64 | cut -d '"' -f 4 | wget -qi -
chmod +x docker-compose-linux-x86_64
sudo mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
```
5. 新增當前使用者至docker
```shell
sudo usermod -aG docker $USER
newgrp docker
```
6. 測試是否成功，輸入`docker version`看到有Server項即為成功，看不到就表示使用者沒有權限看到Server的選項，第5步失敗。
```shell
$ docker version
Client: Docker Engine - Community
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:03:17 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:01:23 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.6
  GitCommit:        10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc:
  Version:          1.1.2
  GitCommit:        v1.1.2-0-ga916309
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
```
7. 輸入` docker-compose version`，若得到如下面所示，則表示成功:
```shell
$ docker-compose version
Docker Compose version v2.14.0
```

### 參考文獻
[Install Docker CE and Docker Compose on Debian 11/10](https://computingforgeeks.com/install-docker-and-docker-compose-on-debian/)
[How To Install Docker Compose on Linux](https://computingforgeeks.com/how-to-install-latest-docker-compose-on-linux/)