筆記:在Ubuntu20.04安裝Docker及Compose
Install docker/docker-compose in Ubuntu 20.04
今天想到自己沒有做個docker安裝的筆記,趕快補上!
安裝前需求套件
sudo apt updatesudo apt -y install apt-transport-https ca-certificates curl gnupg lsb-release
加入gpg key
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
安裝docker套件
sudo apt updatesudo apt -y install docker-ce docker-ce-cli containerd.io
設定群組權限
將docker加入,這樣就不用每次docker時要sudo,而且使用VSCode remote development也需要這個設定sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
參考: https://docs.docker.com/engine/install/linux-postinstall/
測試
docker run hello-world
docker會去官方repository抓示範用的image,只會印出歡迎訊息。
安裝Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
參考: https://docs.docker.com/compose/install/
留言