docker installation (updated)

Past

1
curl -sSL https://get.docker.com/ | sudo sh

還是可以用,但官方文件沒有推薦這種做法。

Present https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
sudo apt-get -y remove docker docker-engine docker.io docker-ce
sudo apt-get update
sudo apt -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88 \#9dc8 5822 9fc7 dd38 854a e2d8 8d81 803c 0ebf CD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

sudo apt-get update 1> /dev/null
sudo apt -y install install docker-ce

apt-cache madison docker-ce
sudo systemctl docker status
docker run hello-world
docker version
docker info

stable/edge/test

依release的穩定度可以有三種選擇。

Uninstall

1
2
sudo apt-get purge docker-ce
sudo rm -rf /var/lib/docker

EE https://docs.docker.com/engine/installation/linux/docker-ee/ubuntu/

建立 Docker 用戶組

默認情況下,docker 命令會使用 Unix socket 與 Docker 引擎通訊。而只有 root 用戶和 docker 組的用戶才可以訪問 Docker 引擎的 Unix socket。因此,將需要使用 docker 的用戶加入 docker 用戶組。

建立 docker 用戶組:

1
sudo groupadd docker

將當前用戶加入 docker 組:

1
sudo usermod -aG docker $USER

測試

1
docker run hello_world

Docker Compose https://docs.docker.com/compose/install/

1
2
3
curl -L https://github.com/docker/compose/releases/download/$dockerComposeVersion/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version

alternative

1
2
3
curl -L --fail https://github.com/docker/compose/releases/download/1.14.0/run.sh > /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose version

Uninstall Docker Compose

1
2
sudo rm /usr/local/bin/docker-compose
\#sudo rm $(which docker-compose)

Docker Machine https://docs.docker.com/machine/install-machine/

1
2
3
curl -L https://github.com/docker/machine/releases/download/v0.12.1/docker-machine-`uname -s`-`uname -m` >/usr/local/bin/docker-machine
sudo chmod +x /usr/local/bin/docker-machine
docker-machine version

Uninstall Docker Machine

1
2
docker-machine rm -f $(docker-machine ls -q)
sudo rm $(which docker-machine)