新增套件
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
加入Docker GPC Key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
加入Docker repo
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
安裝Docker CE
sudo apt-get install docker-ce
運行官方Hello world image測試運作是否正常
sudo docker run hello-world
安裝docker-compose
pip install -U docker-compose
為docker加入sudo權限
sudo groupadd docker sudo usermod -aG docker $USER
如果出現
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/json: dial unix /var/run/docker.sock: connect: permission denied
則:
sudo chmod 666 /var/run/docker.sock
重啟docker
sudo service docker restart
刷新docker group成員
newgrp docker
開機自動啟動Docker
sudo systemctl enable docker