ubuntu和centos安装docker
欧拉系统离线安装docker
https://blog.csdn.net/feifeiyechuan/article/details/129314938
一. UBUNTU系统上
1. 卸载旧版本(新系统不用执行)
2. 安装docker
#step 1: 安装必要的一些系统工具 sudo apt-get update sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
#step 2: 安装GPG证书 curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - #curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
#Step 3: 写入软件源信息 sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" #sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
#Step 4: 更新并安装Docker-CE sudo apt-get -y update sudo apt-get -y install docker-ce
(k8s中docker版本太新会报警告,目前19.05前安全)
sudo apt-get update sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" sudo apt-get -y update apt-get install -y docker-ce=$(apt-cache madison docker-ce | grep 19.03 | head -1 | awk '{print $3}') cat > /etc/docker/daemon.json { "exec-opts": ["native.cgroupdriver=systemd"], "log-driver": "json-file", "log-opts": { "max-size": "100m" }, "storage-driver": "overlay2", "storage-opts": [ "overlay2.override_kernel_check=true" ] }
卸载docker
查看所有apt-get安装的列表 dpkg -l 卸载docker apt-get --purge remove docker-ce apt-get remove docker docker-engine docker.io containerd runc (第一条报错再加这一条)
二. CENTOS安装docker
1. centos6安装docker1.71很简单, 如下,但是不支持docker-compose,因为docker版本太低
2. 在centos6上跑docker和docker-compose
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org #导入public key rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm #安装ELRepo到centos yum --enablerepo=elrepo-kernel install kernel-ml -y #安装kernel,后缀ml是最新版,lt事稳定版
vim /etc/grub.conf 修改第一行为default=0 #修改grub引导顺序,一般新安装的内核在第一个位置,设置default=0,表示启动新内核
最后重启系统即可
yum install epel-release -y
yum install docker-io -y #安装docker1.7.1 curl -sSL -O https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 #下载1.9.1,我是用香港aliyun服务器下载的,国内的好像不行
# wget -c https://get.docker.com/builds/Linux/x86_64/docker-1.10.3 下载docker-1.10版的地址,但是在6上貌似不可用
chmod +x docker-1.9.1 mv docker-1.9.1 /usr/bin/docker #替换 service docker restart docker version #查看版本
3. centos7上安装docker
Uninstall old versions
Older versions of Docker were called docker or docker-engine. If these are installed, uninstall them, along with associated dependencies.
Install Docker CE
Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the devicemapper storage driver.
Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well.
Install the latest version of Docker CE
Start Docker.
Verify that docker is installed correctly by running the hello-world image.
Uninstall Docker CE
Uninstall the Docker package
Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes
4. 卸载docker
三. 安装docker-compose
https://github.com/docker/compose/releases