合 Linux安装Docker并配置加速和自动补全
Tags: LinuxDocker安装部署安装加速二进制安装镜像加速自动补全
docker-compose安装请参考:https://www.dbaup.com/linuxanzhuang-docker-compose.html
一、安装简介
Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上。CentOS 7 的内核一般都是3.10的,而CentOS 6.X 的内核一般都是2.6,在2.6的内核下,Docker运行会比较卡,所以一般会选择升级到3.10版本。
二、在CentOS 7上安装Docker常用命令
yum安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | -- 1、卸载掉旧版本的 Docker: yum remove -y docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine -- 关闭SELINUX sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config -- 一定要重启OS! -- 查询返回disabled getenforce sestatus -- 2、执行以下安装命令去安装依赖包:https://download.docker.com/linux/centos/7/x86_64/stable/Packages/ yum install -y yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo yum -y install docker-ce docker-ce-cli containerd.io docker-compose docker-compose-plugin -- 若执行报错,则配置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 systemctl start docker systemctl status docker -- 检查版本 docker version docker info docker run hello-world -- docker命令补全 yum install -y bash-completion chmod 755 /usr/share/bash-completion/bash_completion sh /usr/share/bash-completion/bash_completion source /usr/share/bash-completion/completions/docker |
一键安装docker
1 2 3 4 5 6 7 8 9 10 | curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun -- 或 curl -fsSL get.docker.com -o get-docker.sh sh get-docker.sh -- 或 curl -sSL https://get.daocloud.io/docker | sh |
离线二进制安装
下载:https://download.docker.com/linux/static/stable/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | wget https://download.docker.com/linux/static/stable/x86_64/docker-24.0.6.tgz tar -zxvf docker-24.0.6.tgz -C /usr/local/ ln -s /usr/local/docker /usr/bin/ ln -s /usr/local/docker/dockerd /usr/bin/dockerd ln -s /usr/local/docker/containerd /usr/bin/containerd ln -s /usr/local/docker/runc /usr/bin/runc echo 'export PATH=/usr/local/docker:$PATH' >> /root/.bashrc chown root.root -R /usr/local/docker cat > /etc/systemd/system/docker.service <<"EOF" [Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service Wants=network-online.target [Service] Type=notify ExecStart=/usr/local/docker/dockerd ExecReload=/bin/kill -s HUP $MAINPID LimitNOFILE=infinity LimitNPROC=infinity TimeoutStartSec=0 Delegate=yes KillMode=process Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s [Install] WantedBy=multi-user.target EOF systemctl daemon-reload systemctl enable docker.service systemctl start docker docker -v |
三、执行过程
1、卸载旧版本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | [root@lhrdocker ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [root@lhrdocker ~]# docker ps bash: docker: command not found... [root@lhrdocker ~]# yum remove -y docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine Loaded plugins: fastestmirror, langpacks Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast No Match for argument: docker No Match for argument: docker-client No Match for argument: docker-client-latest No Match for argument: docker-common No Match for argument: docker-latest No Match for argument: docker-latest-logrotate No Match for argument: docker-logrotate No Match for argument: docker-selinux No Match for argument: docker-engine-selinux No Match for argument: docker-engine No Packages marked for removal |
代码行数不见了
.copy-button {
visibility: hidden;
}
阿凡达
加载慢吗?
不慢,服务器已升级!!!