環境
操作系統:ubuntu 16.04 64位,默認安裝
准備
1. 添加GPG
key:
$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
2. 添加源
新建文件:/etc/apt/sources.list.d/docker.list
,在里面添加內容:
deb https://apt.dockerproject.org/repo ubuntu-xenial main
3. 更新源
$ sudo apt update
安裝與測試
安裝
$ sudo apt install docker-engine
啟動與測試
$ sudo service docker start
$ sudo docker run hello-world
hello-world為鏡像,該鏡像會從鏡像庫中下載,執行的結果如下:
配置開機啟動
配置
$ sudo systemctl enable docker
使用當前用戶執行
如果使用當前用戶執行, 會報如下錯誤:
$ docker run hello-world Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?
所以,需要將當前用戶加入到組docker下,該組是在安裝docker的時候自動建立的。
$ sudo usermod -aG docker ubuntu
整個安裝過程,參考 https://docs.docker.com/engine/installation/linux/ubuntulinux/