redhat7.7安裝docker全過程
1、準(zhǔn)備
官網(wǎng)有二進(jìn)制文件安裝的詳細(xì)過程可參閱:https://docs.docker.com/engine/install/binaries/
下載二進(jìn)制安裝包:
轉(zhuǎn)到 https://download.docker.com/linux/static/stable/ (或更改stable為nightly或test),選擇您的硬件平臺(tái),然后下載.tgz與要安裝的Docker Engine版本有關(guān)的文件。
2、安裝
2.1 安裝gcc相關(guān)環(huán)境
yum -y install gcc yum -y install gcc-c++
2.2. 卸載舊版本,并安裝需要的軟件包
#卸載 yum -y remove docker docker-common docker-selinux docker-engine yum install -y yum-utils device-mapper-persistent-data lvm2
2.3. 設(shè)置stable鏡像倉庫
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
2.4.更新yum軟件包索引
yum makecache fast
2.5.安裝DOCKER CE
yum -y install docker-ce
2.6.啟動(dòng)docker與測(cè)試
#啟動(dòng) systemctl start docker #測(cè)試 docker version docker run hello-world
3、設(shè)置開機(jī)自啟動(dòng)
#關(guān)閉docker服務(wù) kill -9 *** #創(chuàng)建啟動(dòng)文件 vim /etc/systemd/system/docker.service 寫入如下內(nèi)容 [Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service Wants=network-online.target [Service] Type=notify # the default is not to use systemd for cgroups because the delegate issues still # exists and systemd currently does not support the cgroup feature set required # for containers run by docker ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock ExecReload=/bin/kill -s HUP $MAINPID # Having non-zero Limit*s causes performance problems due to accounting overhead # in the kernel. We recommend using cgroups to do container-local accounting. LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity # Uncomment TasksMax if your systemd version supports it. # Only systemd 226 and above support this version. #TasksMax=infinity TimeoutStartSec=0 # set delegate yes so that systemd does not reset the cgroups of docker containers Delegate=yes # kill only the docker process, not all processes in the cgroup KillMode=process # restart the docker process if it exits prematurely Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s [Install] WantedBy=multi-user.target #賦權(quán) chmod +x /etc/systemd/system/docker.service
4、驗(yàn)證
# 重載systemd下 xxx.service文件 systemctl daemon-reload # 啟動(dòng)Docker systemctl start docker #重啟 systemctl restart docker # 設(shè)置開機(jī)自啟 systemctl enable docker.service 注這時(shí)候systemctl stop docker 命令可能不成功,reboot重啟后所有命令生效 完成用二進(jìn)制文件安裝docker??!
5、docker run報(bào)錯(cuò)
#報(bào)錯(cuò)container init caused \“write /proc/self/attr/keycreate: permission denied\““: unknown 原因“/proc/self/attr/keycreate” 這里沒有寫入權(quán)限,把“/etc/selinux/config”里面的SELINUX值修改為disabled SELINUX=disabled
6、docker鏡像本地的導(dǎo)入與恢復(fù)
#查看鏡像 docker images #保存本地 docker save 999c20aee5da > /home/artipub.tar 999c20aee5da為鏡像ID #本地導(dǎo)入docker docker load < /Volumes/SoftWare/artipub.tar #改名 docker tag 999c20aee5da artipub:latest
7、配置鏡像加速
mkdir -p /etc/docker vim /etc/docker/daemon.json systemctl daemon-reload systemctl restart docker
8、總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Linux搭建Docker環(huán)境的詳細(xì)過程(最新推薦)
Docker從17.03版本之后分為CE(Community Edition: 社區(qū)版)和EE(Enterprise Edition: 企業(yè)版),相對(duì)于社區(qū)版本,企業(yè)版本強(qiáng)調(diào)安全性,但需付費(fèi)使用,這里我們使用社區(qū)版本即可,這篇文章給大家介紹Linux搭建Docker環(huán)境的詳細(xì)過程,感興趣的朋友一起看看吧2025-04-04
Docker訪問宿主機(jī)IP的5種方法及最佳實(shí)踐
本文主要介紹了Docker容器訪問宿主機(jī)IP的5種實(shí)用方法,解決容器與宿主機(jī)網(wǎng)絡(luò)通信難題,適用于開發(fā)調(diào)試、服務(wù)調(diào)用等場(chǎng)景,具有一定的參考價(jià)值,感興趣的可以了解一下2026-04-04
使用minikube安裝使用單機(jī)版K8S方式(docker)
本文介紹了如何在centos7上使用minikube快速搭建單機(jī)版k8s,主要步驟包括:下載kubectl和docker,創(chuàng)建新用戶,下載和安裝minikube,驗(yàn)證安裝情況,最后,通過執(zhí)行minikube和minikubestop啟停K8s,或使用minikubedelete徹底刪除K8S的數(shù)據(jù)2024-10-10

