解決docker run hello-world遇到錯(cuò)誤消息-error during conne
docker run hello-world遇到錯(cuò)誤消息-error during conne
執(zhí)行命令行:
docker run hello-world

遇到錯(cuò)誤消息:
docker: error during connect: This error may indicate that the docker daemon is not running.: Post “http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/create”: open //./pipe/docker_engine: The system cannot find the file specified.
See ‘docker run --help’.
錯(cuò)誤消息里已經(jīng)解釋清楚原因了:docker daemon 沒有啟動(dòng)。
進(jìn)到文件夾:C:\Program Files\Docker\Docker
執(zhí)行 DockerCli -switchDaemon 之后,

任務(wù)欄里看到這個(gè) icon:

之后執(zhí)行成功:

這條消息打印的背后,執(zhí)行了這些事情:
(1) The Docker client contacted the Docker daemon.
Docker 客戶端同 docker daemon 連接
(2) The Docker daemon pulled the “hello-world” image from the Docker Hub.
(windows-amd64, nanoserver-1809)
因?yàn)檫@個(gè)命令是第一次執(zhí)行,Docker daemon 從 docker hub 網(wǎng)站,將 hello-world 鏡像下載到本地。
(3) The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.
Docker daemon 基于下載好的鏡像,創(chuàng)建一個(gè)新的容器,后者運(yùn)行鏡像,產(chǎn)生一條輸出消息
(4) The Docker daemon streamed that output to the Docker client, which sent it to your terminal.
Docker daemon 將輸出發(fā)給 docker 客戶端,后者再發(fā)到 Windows 控制臺(tái)。
docker安裝以及docker run hello-world 不能下載鏡像報(bào)錯(cuò)
官方Docker 的文檔地址
https://docs.docker.com/engine/install/centos/
以下的代碼需要連接 Linux的Centos服務(wù)器,Xshell執(zhí)行
1.刪除之前的版本
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine2.設(shè)置存儲(chǔ)庫 需要的安裝包
yum install -y yum-utils
3.設(shè)置鏡像(這里我用的是阿里云的鏡像,默認(rèn)是國外的太慢了)
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repohttps://pi9dpp60.mirror.aliyuncs.com 上面的網(wǎng)址最好用這個(gè)網(wǎng)址代替,這個(gè)是阿里云的個(gè)人鏡像加速,上面的可能會(huì)出錯(cuò),詳情請(qǐng)向下看
4.安裝最新版的Docker引擎 ce社區(qū) ee企業(yè)
yum install docker-ce docker-ce-cli containerd.io
5.啟動(dòng)Docker
systemctl start docker
6.看看Docker是否安裝
docker version
下圖就是成功頁面

7.hello world 測(cè)試
出現(xiàn)以下圖片是正常

測(cè)試安裝鏡像
docker pull mysql 就會(huì)安裝mysql最新版本
但是?。。。。?!我出現(xiàn)以下錯(cuò)誤:
docker: Error response from daemon: Head https://registry-1.docker.io/v2/library/hello-world/manifests/latest:
Get https://auth.docker.io/token?scope=repository%3Alibrary%2Fhello-world%3Apull&service=registry.docker.io: read tcp 172.18.232.161:33136->54.165.240.225:443: read: connection reset by peer.
See 'docker run --help'.
意思就是鏡像沒弄好,我們需要配置下鏡像加速器就好了。
我的是阿里云的服務(wù)器,登陸到控制臺(tái)-容器鏡像服務(wù)-鏡像加速器
將里邊的,代碼一行一行執(zhí)行即可,如下:
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://pi9dpp60.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker卸載Docker
sudo yum remove docker-ce docker-ce-cli containerd.io
刪除目錄和卷
sudo rm -rf /var/lib/docker sudo rm -rf /var/lib/containerd
Docker所有的鏡像都會(huì)在DockerHub上面下載。
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
DockerCE之執(zhí)行docker info出現(xiàn)兩條警告信息及解決方案
這篇文章主要介紹了DockerCE之執(zhí)行docker info出現(xiàn)兩條警告信息及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-02-02
解決docker安裝jenkins容器內(nèi)無法訪問外網(wǎng)
這篇文章為大家主要介紹了docker安裝jenkins容器內(nèi)無法訪問外網(wǎng)的問題解決,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-11-11
優(yōu)化Docker容器啟動(dòng)時(shí)間的常見方案
優(yōu)化 Docker 容器啟動(dòng)時(shí)間,尤其在大規(guī)模部署、CI/CD 或微服務(wù)架構(gòu)中非常關(guān)鍵,啟動(dòng)慢會(huì)影響響應(yīng)時(shí)間、彈性擴(kuò)縮容和用戶體驗(yàn),以下是從鏡像構(gòu)建、容器運(yùn)行、依賴管理等多個(gè)方面整理的 容器啟動(dòng)加速方案,需要的朋友可以參考下2025-06-06
Docker本地部署SSR前端項(xiàng)目實(shí)戰(zhàn)指南
本文介紹了Docker本地部署SSR前端項(xiàng)目實(shí)戰(zhàn)指南,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2026-01-01

