ubuntu18.04 安装docker,docker-compose

  • ubuntu 18.04 安装docker
#卸载旧版本
$ sudo apt-get remove docker docker-engine docker.io containerd runc

# 更新数据源
$ sudo apt-get update
# 安装所需依赖 
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

# 安装 GPG 证书(9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88)
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# 通过 搜索后8位校验
Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.

root@VM-0-3-ubuntu:/usr/local# sudo apt-key fingerprint 0EBFCD88
pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) 
sub   rsa4096 2017-02-22 [S]
# 新增数据源(二选一)
#官网数据源下载
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
#阿里云 下载地址
$ sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

# 安装docker engine (docker-ce-cli 可以不安装)
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io

# 镜像加速器(个人阿里云镜像加速)
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://pak80xoo.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
#重启docker 服务
service docker restart

#查看docker 版本
docker info



--------------------------版本信息 start ---------------------------------
Client:
 Debug Mode: false
Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 19.03.8
 Storage Driver: overlay2
  Backing Filesystem: 
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 4.15.0-54-generic
 Operating System: Ubuntu 18.04.1 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.696GiB
 Name: VM-0-3-ubuntu
 ID: AXDP:4IZF:XFXW:ZHS4:YTZO:OUPV:CK4Q:S5US:CQ4S:JLS2:B6JE:ZYBV
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
  https://pak80xoo.mirror.aliyuncs.com/  #阿里云镜像加速
 Live Restore Enabled: false
-----------------------------------end-----------------------------------------
  • docker-compose 安装
#docker-compose 镜像加速(http://get.daocloud.io/)
curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
root@VM-0-3-ubuntu:/usr/local/docker# curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   423  100   423    0     0     70      0  0:00:06  0:00:05  0:00:01   112
100 16.3M  100 16.3M    0     0  2365k      0  0:00:07  0:00:07 --:--:-- 5908k

  • docker-compose 文件夹授权
chmod +x /usr/local/bin/docker-compose
  • docker-compose 版本查看
#版本信息查看
docker-compose info

root@VM-0-3-ubuntu:/usr/local/docker# docker-compose info
-bash: /usr/local/bin/docker-compose: Permission denied
root@VM-0-3-ubuntu:/usr/local/docker# docker-compose version
-bash: /usr/local/bin/docker-compose: Permission denied
root@VM-0-3-ubuntu:/usr/local/docker# chmod +x /usr/local/bin/docker-compose
root@VM-0-3-ubuntu:/usr/local/docker# docker-compose version
docker-compose version 1.25.4, build 8d51620a
docker-py version: 4.1.0
CPython version: 3.7.5
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

你可能感兴趣的:(linux)