Site icon 咖啡偶-IT日常

ubuntu 20.04 安裝docker

1. 
sudo apt-get update
sudo apt-get install \
     apt-transport-https \
     ca-certificates \
     curl \
     gnupg \
     lsb-release
	 
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
	 
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
##$(lsb release -cs) 試圖找出ubuntu對應版本 , 
##或是到這查https://download.docker.com/linux/ubuntu/dists/
  
sudo apt-get install docker-ce docker-ce-cli containerd.io

2. 自訂存放目錄

修改 /lib/systemd/system/docker.service
 從
ExecStart=/usr/bin/docker daemon -H fd://
 改成
ExecStart=/usr/bin/docker daemon --data-root <自訂目錄> -H fd:// 

重啟 docker 
systemctl stop docker
systemctl daemon-reload
systemctl start docker

完成
Exit mobile version