docker安装


docker版本号之前一直是0.X版本或1.X版本,但是从2017年3月1号开始改为每个季度发布一次稳版,其版本号规则也统一变更为YY.MM,例如17.09表示是2017年9月份发布

CE(Docker Community Edition,社区版本)和 EE(Docker Enterprise Edition,企业收费版)



1
.Ubuntu 14.04/16.04/18.04 安装docker # 删除老版本docker [root@ubuntu ~]#apt purge docker-ce [root@ubuntu ~]#rm -rf /var/lib/docker #安装必要的一些系统工具 sudo apt-get update sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common #安装GPG证书 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" #查找Docker-CE的版本: apt-cache madison docker-ce #更新并安装Docker-CE sudo apt-get -y update sudo apt-get -y install docker-ce 2.基于 ubuntu1804 的 docker-ce 安装脚本 [root@ubuntu1804 ~]#cat install_docker_ubuntu.sh #!/bin/bash #Description: Install docker on Ubuntu1804 #Version:1.0 #Date:2020-01-22 COLOR="echo -e \\033[1;31m" END="\033[m" DOCKER_VERSION="5:19.03.5~3-0~ubuntu-bionic" install_docker(){ dpkg -s docker-ce &> /dev/null && ${COLOR}"Docker已安装,退出"${END} && exit apt update apt -y install apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" apt update ${COLOR}"Docker有以下版本"${END} apt-cache madison docker-ce ${COLOR}"5秒后即将安装: docker-"${DOCKER_VERSION}" 版本....."${END} ${COLOR}"如果想安装其它Docker版本,请按ctrl+c键退出,修改版本再执行"${END} sleep 5 apt -y install docker-ce=${DOCKER_VERSION} docker-ce-cli=${DOCKER_VERSION} #使用阿里做镜像加速 mkdir -p /etc/docker tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://si7y70hh.mirror.aliyuncs.com"] } EOF systemctl daemon-reload systemctl restart docker docker version && ${COLOR}"Docker 安装成功"${END} || ${COLOR}"Docker 安装失败"${END} } install_docker

 

Cnetos7版本安装 docker

一。Cnetos7版本安装 docker

1.卸载旧版本
较旧的 Docker 版本称为 docker 或 docker-engine 。如果已安装这些程序,请卸载它们以及相关的依赖项。
yum remove docker docker-client docker-client-latest docker-common docker-latest 
docker-latest-logrotate docker-logrotate  docker-engine

2.下载YUM源
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


3.安装指定版本:docker  docker-compose
yum list docker-ce --showduplicates
yum install docker-ce-19.03.15-3.el7  docker-ce-cli-19.03.15-3.el7
yum install docker-compose
systemctl enable docker  systemctl start docker


二。基于CentOS 7的一键安装脚本
[root@centos7 ~]#cat install_docker_for_centos7.sh 
#!/bin/bash
COLOR="echo -e \\033[1;31m"
END="\033[m"
VERSION="19.03.5-3.el7"
wget -P /etc/yum.repos.d/ https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo  || { ${COLOR}"互联网连接失败,请检查网络配置!"${END};exit; }
yum clean all 
yum -y install docker-ce-$VERSION docker-ce-cli-$VERSION || { ${COLOR}"Base,Extras的yum源失败,请检查yum源配置"${END};exit; }



三。基于CentOS 7的二进制安装Docker
[root@centos7 ~]#wget https://download.docker.com/linux/static/stable/x86_64/docker-19.03.5.tgz
[root@centos7 ~]#tar xvf docker-19.03.5.tgz 
[root@centos7 ~]#cp docker/* /usr/bin/
[root@centos7 ~]#groupadd -r docker
#将Ubuntu1804或CentOS7基于yum包方式安装的相关文件复制到相应目录下
[root@ubuntu1804 ~]#scp /lib/systemd/system/docker.* /lib/systemd/system/containerd.service  LOCALHOST:/lib/systemd/system/
[root@centos7 ~]#systemctl daemon-reload
[root@centos7 ~]#systemctl enable --now docker

 

在CentOS8上安装docker
在CentOS8上安装docker
#在CentOS8上安装docker会自动安装podman,docker工具只是一个脚本,调用了Podman

[root@centos8 ~]#dnf install docker
[root@centos8 ~]#rpm -ql podman-docker
/usr/bin/docker
[root@centos8 ~]#cat /usr/bin/docker
#!/bin/sh
[ -f /etc/containers/nodocker ] || \
echo "Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg." >&2
exec /usr/bin/podman "$@"
[root@centos8 ~]#podman version
Version:            1.4.2-stable2
RemoteAPI Version:  1
Go Version:         go1.12.8
OS/Arch:            linux/amd64

#修改拉取镜像的地址的顺序,提高速度
[root@centos8 ~]#vim /etc/containers/registries.conf
[registries.search]
registries = ['docker.io''quay.io''registry.redhat.io', 'registry.access.redhat.com'] 

1.容器软件安装:Debian 系统安装基础命令:
# apt update
# apt-get update
# apt install procps (top 命令)
# apt install iputils-ping (ping 命令)
# apt install net-tools (网络工具)

2.容器软件安装:Alpine 系统安装基础命令:
#修改源替换成阿里源,将里面 dl-cdn.alpinelinux.org 的 改成 mirrors.aliyun.com
vi etc/apk/repositories
http://mirrors.aliyun.com/alpine/v3.8/main/
http://mirrors.aliyun.com/alpine/v3.8/community/


apk update    #更新源
apk add vim   #安装软件
apk del openssh openntp vim    #删除软件  

apk search openssh #查询openssh相关的软件包
apk --help                     #获取更多apk包管理的命令参数 


3.容器软件安装:Cenots 系统安装基础命令:

 

posted @ 2022-10-14 17:17  yuanbangchen  阅读(74)  评论(0编辑  收藏  举报