如何安裝docker桌面版本

使用環境

OS:ubuntu 22.04 LTS

docker桌面版本限定只能22.04或更高的版本才能運行

設定 repository

1
sudo apt-get update
1
2
3
4
5
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release

填加docker官方金鑰

1
2
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
1
2
3
4
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

安裝docker引擎

1
2
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

查詢可安裝的版本

1
apt-cache madison docker-ce

安裝docker

1
sudo apt-get install docker-ce=<VERSION> docker-ce-cli=<VERSION> containerd.io docker-compose-plugin

例如: sudo apt-get install docker-ce=5:20.10.16~3-0~ubuntu-jammy docker-ce-cli=5:20.10.16~3-0~ubuntu-jammy containerd.io docker-compose-plugin

安裝docker desktop介面

先到這裡找到想要下載deb檔版本
https://docs.docker.com/desktop/release-notes/

1
2
3
curl -O https://desktop.docker.com/linux/main/amd64/docker-desktop-<version>-<arch>.deb
sudo apt-get update
sudo apt-get install ./docker-desktop-<version>-<arch>.deb

假設我們要下載這個版本docker-desktop-4.10.1-amd64.deb

1
2
3
curl -O https://desktop.docker.com/linux/main/amd64/docker-desktop-4.10.1-amd64.deb
sudo apt-get update
sudo apt-get install ./docker-desktop-4.10.1-amd64.deb

這裡報錯可忽略
1
2
3
N: Download is performed unsandboxed as root, as file 
'/home/user/Downloads/docker-desktop.deb' couldn't be accessed by user
'_apt'. - pkgAcquire::Run (13: Permission denied)

啟動Docker Desktop

1
2
3
4
5
6
7
systemctl --user start docker-desktop (記得不要在root帳號下用,要在一般使用者底下用)
docker compose version
docker --version
docker version
systemctl --user enable docker-desktop #開機啟動
systemctl --user stop docker-desktop #停止

在虛擬機上建docker desktop出現一直stopped解法[3]

1
2
3
4
5
6
7
8
9
10
11
12
modprobe kvm

modprobe kvm_intel #Intel processors
modprobe kvm_amd #AMD processors

kvm-ok

lsmod | grep kvm

ls -al /dev/kvm

sudo usermod -aG kvm $USER

參考資料

  1. https://docs.docker.com/engine/install/ubuntu/#set-up-the-repository
  2. https://docs.docker.com/desktop/install/ubuntu/
  3. https://docs.docker.com/desktop/install/linux-install/