以下為ubuntu20.04
Linux 安裝docker
在 Ubuntu Linux 中,使用 apt 安裝 Docker 比較方便:
sudo apt-get install docker.io

安裝好之後,查看一下 docker 服務是否有正常啟動:
service docker status
正常的話,應該可以看到綠色的狀態:
sudo usermod -aG docker 使用者名稱

docker version


Linux 安裝docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo gpasswd -a ${USER} docker

docker 切換使用者
- 將使用者加入群組
sudo gpasswd -a ${USER} docker
- 切換到超級使用者
sudo su
- 切回使用者
su ubuntu
更新apt包资源索引
sudo apt-get update
安裝軟件包以允許apt通過HTTPS使用存儲庫:
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
重新開啟docker
有次早上要執行docker-compose的時候無法正常開啟,出現下方錯誤訊息
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
當時已經設好群組卻還是一樣,所以有可能就是docker不知道原因被關閉了。
下方指令為重新開啟docker的方式。
service docker start
sudo docker-compose up