Docker(一) centos和Ubuntu系统安装docker

文章目录

  • Docker安装
    • Centos yum源安装:
  • Ubuntu安装
    • 阿里云一键安装脚本最新版
    • 自定义版本下载

Docker版本选择:

Docker之前没有区分版本,但是2017年推出(将docker更名为)新的项目Moby,github地址:https://github.com/moby/moby,Moby项目属于Docker项目的全新上游,Docker将是一个隶属于的Moby的子产品,而且之后的版本之后开始区别为CE版本(社区版本)和EE(企业收费版),CE社区版本和EE企业版本都是每个季度发布一个新版本,但是EE版本提供后期安全维护1年,而CE版本是4个月

Docker安装

下载rpm包安装:
官方rpm包下载地址:

https : //download.docker.com/linux/centos/7/x86_64/stable/Packages/

阿里云下载地址:

https ://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/

Centos yum源安装:

下载docker源

rm -rf /etc/yum.repos.d/*
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

安装

yum install docker-ce -y

启动

systemctl start docker
systemctl enable docker

Ubuntu安装

版本:Ubuntu 18.04.3

阿里云一键安装脚本最新版

使用官方安装脚本自动安装(仅适用于公网环境)

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

自定义版本下载

配置阿里yum源

sudo vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

安装必要的一些系统工具

sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
  1. 安装GPG证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
  1. 写入软件源信息
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
  1. 更新
sudo apt-get -y update
  1. 发现Docker-CE的版本:
# apt-cache madison docker-ce
docker-ce | 5:19.03.2~3-0~ubuntu-bionic | http://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages
docker-ce | 5:19.03.1~3-0~ubuntu-bionic | http://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages
  1. 安装指定版本的Docker-CE:(VERSION例如上面的17.03.1〜ce-0〜ubuntu-xenial)
sudo apt install docker-ce-cli=5:18.09.9~3-0~ubuntu-bionic
sudo apt install docker-ce=5:18.09.9~3-0~ubuntu-bionic
  1. 验证版本,或使用docker version
    Docker(一) centos和Ubuntu系统安装docker_第1张图片8、验证docker信息 (以下是ubuntu安装的信息)
# docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 18.09.9
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host 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: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc version: 425e105d5a03fabd737a126ad93d62a9eeede87f
init version: fec3683
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.15.0-62-generic
Operating System: Ubuntu 18.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.861GiB
Name: ubuntu
ID: 2C5Z:IASC:G3GK:325R:RDGI:GDJ4:23EE:O76B:Z2RY:HY5U:RSLC:J7OO
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

WARNING: No swap limit support
 

最后一行有个警告:警告:不支持交换限制
解决方法:

sudo vim /etc/default/grub

在GRUB_CMDLINE_LINUX=""这行加上

GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"

更新下grub,然后重启

sudo update-grub
reboot

你可能感兴趣的:(Llinux,docker)