在linux上安裝Docker

安裝參考Docker

INSTALL DOCKER CE
Update the apt package index.

$ sudo apt-get update
Install the latest version of Docker CE, or go to the next step to install a specific version:

$ sudo apt-get install docker-ce
Got multiple Docker repositories?

If you have multiple Docker repositories enabled, installing or updating without specifying a version in the apt-get install or apt-get update command always installs the highest possible version, which may not be appropriate for your stability needs.

To install a specific version of Docker CE, list the available versions in the repo, then select and install:

a. List the versions available in your repo:

$ apt-cache madison docker-ce

docker-ce | 18.09.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
b. Install a specific version by its fully qualified package name, which is package name (docker-ce) “=” version string (2nd column), for example, docker-ce=18.03.0~ce-0~ubuntu.

$ sudo apt-get install docker-ce=
The Docker daemon starts automatically.

Verify that Docker CE is installed correctly by running the hello-world image.

$ sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

若不是使用root帳號,則要執行docker指令前,需要先將”自己的帳號”加入docker群組,其中usermod(user modify),-G:修改附加群組

sudo usermod -aG docker your-user

加入後,先重新登入帳號,群組修改才能生效,確認加入群組是否成功,可輸入 groups
listUserGroup

切換到root帳號

sudo su -