Ubuntu安装docker
-
基础软件安装
# 安装基本软件
$ sudo apt-get update
$ sudo apt-get install apt-transport-https ca-certificates curl git software-properties-common lrzsz -y -
添加阿里的docker镜像仓库
# 添加阿里的docker镜像仓库
$ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# 更新软件源
$ sudo apt-get update -
安装docker
# 安装docker
$ sudo apt-get install docker-ce -y
# 查看安装的docker版本
$ docker version
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:24:51 2018
OS/Arch: linux/amd64
Experimental: false
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.38/version:
dial unix /var/run/docker.sock: connect: `permission denied`
# 当前用户直接操作docker时, 权限不够, 需要做下面的第4不操作 -
将当前用户添加到docker组
# 将用户加入该 group 内。然后退出并重新登录就生效啦。
$ sudo gpasswd -a ${USER} docker
# 重启docker服务
$ systemctl restart docker
# 当前用户切换到docker群组
$ newgrp - docker
$ docker version
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:24:51 2018
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.06.1-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:23:15 2018
OS/Arch: linux/amd64
Experimental: false -
安装docker-compose
#安装依赖工具
$ sudo apt-get install python3-pip -y
#安装编排工具
$ sudo pip3 install docker-compose
#查看版本
$ sudo docker-compose version