centos下docker安装
一、设置存储库
1 | yum-config-manager --add-repo https: //download .docker.com /linux/centos/docker-ce .repo |
执行结果
1 2 3 | 已加载插件:fastestmirror, langpacks adding repo from: https: //download .docker.com /linux/centos/docker-ce .repo grabbing file https: //download .docker.com /linux/centos/docker-ce .repo to /etc/yum .repos.d /docker-ce .repo<br>repo saved to /etc/yum .repos.d /docker-ce .repo |
二、安装docker-ce(docker-ce是社区免费版,docker-ee是企业版)
1 | yum install -y docker-ce |
出现错误
1 | 获取 GPG 密钥失败:[Errno 14] curl #35 - "Network file descriptor is not connected" |
到http://mirrors.163.com找到对应版本
1 | rpm -- import http: //mirrors .163.com /centos/RPM-GPG-KEY-CentOS-7 |
再次安装docker-ce成功
三、启动docker
1 | systemctl daemon-reload && systemctl start docker |
验证
1 | docker version |
Client: Docker Engine - Community Version: 19.03.7 API version: 1.40 Go version: go1.12.17 Git commit: 7141c199a2 Built: Wed Mar 4 01:24:10 2020 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 19.03.7 API version: 1.40 (minimum version 1.12) Go version: go1.12.17 Git commit: 7141c199a2 Built: Wed Mar 4 01:22:45 2020 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.2.13 GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429 runc: Version: 1.0.0-rc10 GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd docker-init: Version: 0.18.0 GitCommit: fec3683
四、运行hello word!
先login(官方文档上说运行helloword不需要login,但会出现docker: Error response from daemon: pull access denied for hell-world, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.错误)
1 2 3 4 5 6 7 8 9 10 11 12 13 | [root@localhost data] # docker run hello-world Unable to find image 'hell-world:latest' locally docker: Error response from daemon: pull access denied for hell-world, repository does not exist or may require 'docker login' : denied: requested access to the resource is denied. See 'docker run --help' . [root@localhost data] # docker login Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https: //hub .docker.com to create one. Username: xxxxx Password: WARNING! Your password will be stored unencrypted in /root/ .docker /config .json. Configure a credential helper to remove this warning. See https: //docs .docker.com /engine/reference/commandline/login/ #credentials-store Login Succeeded |
运行hello-world
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 | [root@localhost data] # docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library /hello-world 1b930d010525: Pull complete Digest: sha256:fc6a51919cfeb2e6763f62b6d9e8815acbf7cd2e476ea353743570610737b752 Status: Downloaded newer image for hello-world:latest 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/ |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· [AI/GPT/综述] AI Agent的设计模式综述