Docker安裝配置鏡像加速器的實現(xiàn)
更新時間:2025年01月08日 09:16:12 作者:還有十四天
本文主要介紹了Docker安裝配置鏡像加速器的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
1.配置yum源倉庫
[root@localhost ~]# curl -o docker-ce.repo https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1919 100 1919 0 0 2357 0 --:--:-- --:--:-- --:--:-- 2357 [root@localhost ~]# sed -i 's@https://download.docker.com@https://mirrors.tuna.tsinghua.edu.cn/docker-ce@g' docker-ce.repo [root@localhost ~]# mv docker-ce.repo /etc/yum.repos.d/ [root@localhost ~]# dnf -y install docker-ce
2.安裝docker
[root@localhost ~]# dnf -y install docker-ce 正在更新 Subscription Management 軟件倉庫。 無法讀取客戶身份 本系統(tǒng)尚未在權(quán)利服務器中注冊??墒褂?subscription-manager 進行注冊。 Docker CE Stable - x86_64 18 kB/s | 56 kB 00:03 上次元數(shù)據(jù)過期檢查:0:00:01 前,執(zhí)行于 2024年09月11日 星期三 09時42分01秒。 依賴關系解決。 ============================================================================================================= 軟件包 架構(gòu) 版本 倉庫 大小 ============================================================================================================= 安裝: docker-ce x86_64 3:27.2.1-1.el9 docker-ce-stable 27 M 安裝依賴關系: containerd.io x86_64 1.7.21-3.1.el9 docker-ce-stable 43 M docker-ce-cli x86_64 1:27.2.1-1.el9 docker-ce-stable 8.0 M 安裝弱的依賴: docker-buildx-plugin x86_64 0.16.2-1.el9 docker-ce-stable 14 M docker-ce-rootless-extras x86_64 27.2.1-1.el9 docker-ce-stable 4.4 M docker-compose-plugin x86_64 2.29.2-1.el9 docker-ce-stable 13 M 事務概要 ============================================================================================================= 安裝 6 軟件包 總下載:109 M 安裝大?。?25 M 下載軟件包: (1/6): docker-ce-27.2.1-1.el9.x86_64.rpm 7.0 MB/s | 27 MB 00:03 (2/6): containerd.io-1.7.21-3.1.el9.x86_64.rpm 7.6 MB/s | 43 MB 00:05 (3/6): docker-ce-cli-27.2.1-1.el9.x86_64.rpm 3.4 MB/s | 8.0 MB 00:02 (4/6): docker-ce-rootless-extras-27.2.1-1.el9.x86_64.rpm 4.8 MB/s | 4.4 MB 00:00 (5/6): docker-buildx-plugin-0.16.2-1.el9.x86_64.rpm 1.8 MB/s | 14 MB 00:07 (6/6): docker-compose-plugin-2.29.2-1.el9.x86_64.rpm 7.6 MB/s | 13 MB 00:01 ------------------------------------------------------------------------------------------------------------- 總計 14 MB/s | 109 MB 00:07 Docker CE Stable - x86_64 2.3 kB/s | 1.6 kB 00:00 導入 GPG 公鑰 0x621E9F35: Userid: "Docker Release (CE rpm) <docker@docker.com>" 指紋: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35 來自: https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/gpg 導入公鑰成功 運行事務檢查 事務檢查成功。 運行事務測試 事務測試成功。 運行事務 準備中 : 1/1 安裝 : docker-compose-plugin-2.29.2-1.el9.x86_64 1/6 運行腳本: docker-compose-plugin-2.29.2-1.el9.x86_64 1/6 安裝 : docker-buildx-plugin-0.16.2-1.el9.x86_64 2/6 運行腳本: docker-buildx-plugin-0.16.2-1.el9.x86_64 2/6 安裝 : docker-ce-cli-1:27.2.1-1.el9.x86_64 3/6 運行腳本: docker-ce-cli-1:27.2.1-1.el9.x86_64 3/6 安裝 : containerd.io-1.7.21-3.1.el9.x86_64 4/6 運行腳本: containerd.io-1.7.21-3.1.el9.x86_64 4/6 安裝 : docker-ce-rootless-extras-27.2.1-1.el9.x86_64 5/6 運行腳本: docker-ce-rootless-extras-27.2.1-1.el9.x86_64 5/6 安裝 : docker-ce-3:27.2.1-1.el9.x86_64 6/6 運行腳本: docker-ce-3:27.2.1-1.el9.x86_64 6/6 驗證 : containerd.io-1.7.21-3.1.el9.x86_64 1/6 驗證 : docker-buildx-plugin-0.16.2-1.el9.x86_64 2/6 驗證 : docker-ce-3:27.2.1-1.el9.x86_64 3/6 驗證 : docker-ce-cli-1:27.2.1-1.el9.x86_64 4/6 驗證 : docker-ce-rootless-extras-27.2.1-1.el9.x86_64 5/6 驗證 : docker-compose-plugin-2.29.2-1.el9.x86_64 6/6 已更新安裝的產(chǎn)品。 已安裝: containerd.io-1.7.21-3.1.el9.x86_64 docker-buildx-plugin-0.16.2-1.el9.x86_64 docker-ce-3:27.2.1-1.el9.x86_64 docker-ce-cli-1:27.2.1-1.el9.x86_64 docker-ce-rootless-extras-27.2.1-1.el9.x86_64 docker-compose-plugin-2.29.2-1.el9.x86_64 完畢!
3.啟動docker
1.啟動docker自動開機
[root@localhost ~]# systemctl enable --now docker Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
2.查看docker的當前狀態(tài)
[root@localhost ~]# systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: disabled) Active: active (running) since Wed 2024-09-11 09:43:49 CST; 17s ago TriggeredBy: ● docker.socket Docs: https://docs.docker.com Main PID: 35124 (dockerd) Tasks: 10 Memory: 25.6M CPU: 787ms CGroup: /system.slice/docker.service └─35124 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock 9月 11 09:43:48 localhost.localdomain systemd[1]: Starting Docker Application Container Engine... 9月 11 09:43:48 localhost.localdomain dockerd[35124]: time="2024-09-11T09:43:48.495682747+08:00" level=info > 9月 11 09:43:48 localhost.localdomain dockerd[35124]: time="2024-09-11T09:43:48.587274179+08:00" level=info > 9月 11 09:43:49 localhost.localdomain dockerd[35124]: time="2024-09-11T09:43:49.349750672+08:00" level=info > ...
4.配置鏡像加速器
1.進入vim文字編輯器
vim /etc/docker/daemon.json
2.編輯內(nèi)容在阿里云官網(wǎng)中搜索并保存退出
{ "registry-mirrors": ["https://8r73devx.mirror.aliyuncs.com"] }
5.重啟docker
systemctl restart docker
6.查看系統(tǒng)版本信息
[root@localhost ~]# docker version Client: Docker Engine - Community Version: 27.2.1 API version: 1.47 Go version: go1.22.7 Git commit: 9e34c9b Built: Fri Sep 6 12:09:42 2024 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 27.2.1 API version: 1.47 (minimum version 1.24) Go version: go1.22.7 Git commit: 8b539b8 Built: Fri Sep 6 12:07:57 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.7.21 GitCommit: 472731909fa34bd7bc9c087e4c27943f9835f111 runc: Version: 1.1.13 GitCommit: v1.1.13-0-g58aa920 docker-init: Version: 0.19.0 GitCommit: de40ad0
7.運行docker
[root@localhost ~]# docker run hello-world Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/ [root@localhost ~]#
到此這篇關于Dockers安裝配置鏡像加速器的實現(xiàn)的文章就介紹到這了,更多相關Dockers安裝配置鏡像加速器內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
利用python自動生成docker nginx反向代理配置
這篇文章主要介紹了利用python自動生成docker nginx反向代理配置的相關資料,完成反向代理盡量簡單,占內(nèi)存少等,需要的朋友可以參考下2017-01-01手動構(gòu)建自己的docker容器鏡像實戰(zhàn)
這篇文章主要介紹了如何手動構(gòu)建自己的鏡像并上傳到鏡像倉庫中,文中有詳細的代碼實例,需要的朋友可以參考閱讀2023-04-04Docker搭建簡單的應用棧與容器Hello World訪問詳解
這篇文章主要介紹了Docker搭建簡單的應用棧與容器Hello World訪問,結(jié)合實例形式詳細分析了Docker應用容器棧的獲取、互聯(lián)、啟動、配置以及應用訪問測試相關操作技巧,需要的朋友可以參考下2018-06-06