您的位置:首页 > 新闻 > 会展 > CentOS安装docker

CentOS安装docker

2025/5/15 4:53:37 来源:https://blog.csdn.net/qq_31860647/article/details/142314042  浏览:    关键词:CentOS安装docker

安装一些系统工具

sudo yum install -y yum-utils

添加docker稳定的仓库(国内访问官方源可能失败,所以使用阿里云的仓库)

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

安装docker

sudo yum install docker-ce docker-ce-cli containerd.io

在这里插入图片描述
安装的时候会问需不需要继续的时候,输入y继续,最后等待即可。

另外,安装完成之后需要把docker模式拉取镜像源改一下,要不然也会访问官方镜像源,可能会无法访问:

sudo tee /etc/docker/daemon.json <<-'EOF'
{"registry-mirrors": ["https://m8y4mh9x.mirror.aliyuncs.com/"]
}
EOF

另外贴几个其他镜像源,可自行选择(如果都用不了了自行搜索其他可用的仓库即可):

网易:http://hub-mirror.c.163.com
中科大镜像地址:http://mirrors.ustc.edu.cn/
中科大github地址:https://github.com/ustclug/mirrorrequest
Azure中国镜像地址:http://mirror.azure.cn/
Azure中国github地址:https://github.com/Azure/container-service-for-azure-china
DockerHub镜像仓库: https://hub.docker.com/ 
阿里云镜像仓库: https://cr.console.aliyun.com 
google镜像仓库: https://console.cloud.google.com/gcr/images/google-containers/GLOBAL (如果你本地可以翻墙的话是可以连上去的 )
coreos镜像仓库: https://quay.io/repository/ 
RedHat镜像仓库: https://access.redhat.com/containers

改完镜像源之后,重启docker

sudo systemctl restart docker

使用下列命令查看一下是否更改成功:

docker info
Client: Docker Engine - CommunityVersion:    26.1.4Context:    defaultDebug Mode: falsePlugins:buildx: Docker Buildx (Docker Inc.)Version:  v0.14.1Path:     /usr/libexec/docker/cli-plugins/docker-buildxcompose: Docker Compose (Docker Inc.)Version:  v2.27.1Path:     /usr/libexec/docker/cli-plugins/docker-composeServer:Containers: 0Running: 0Paused: 0Stopped: 0Images: 0Server Version: 26.1.4Storage Driver: overlay2Backing Filesystem: extfsSupports d_type: trueUsing metacopy: falseNative Overlay Diff: trueuserxattr: falseLogging Driver: json-fileCgroup Driver: cgroupfsCgroup Version: 1Plugins:Volume: localNetwork: bridge host ipvlan macvlan null overlayLog: awslogs fluentd gcplogs gelf journald json-file local splunk syslogSwarm: inactiveRuntimes: io.containerd.runc.v2 runcDefault Runtime: runcInit Binary: docker-initcontainerd version: d2d58213f83a351ca8f528a95fbd145f5654e957runc version: v1.1.12-0-g51d5e94init version: de40ad0Security Options:seccompProfile: builtinKernel Version: 3.10.0-1160.119.1.el7.x86_64Operating System: CentOS Linux 7 (Core)OSType: linuxArchitecture: x86_64CPUs: 2Total Memory: 1.715GiBName: XanaduInstanceHostID: acd5df4a-dab2-4bef-b72c-b9ddd50ef8d0Docker Root Dir: /var/lib/dockerDebug Mode: falseExperimental: falseInsecure Registries:127.0.0.0/8Registry Mirrors:https://m8y4mh9x.mirror.aliyuncs.com/Live Restore Enabled: false

在倒数第二行可以看到已经修改成功了,现在可以正常拉取镜像了。

注意:如果例子里的镜像用不了了,更换其他可用的源。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com