在CentOS、Fedora系统中使用Docker的方法

发布时间:2022-05-02 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了在CentOS、Fedora系统中使用Docker的方法脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

一、从docker官方yum进行安装

1、添加docker官方源

cat >/etc/yum.repos.d/docker.repo <<-EOF
[dockerrepo]
name=Docker ReposITory
baseurl=https://yum.dockerPRoject.org/repo/main/centos/7
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

2、安装和启动

#安装
sudo yum install docker-engine
#启动
sudo Systemctl enable docker.service
#开机启动
systemctl enable docker.service
#验证安装
sudo docker run hello-world

二、用脚本的方式安装

curl -sSL https://get.docker.COM/ | sh

三、非特权用户运行 docker 命令

在 CentOS 或 Fedora 上安装完成 Docker 后,为了能以非 root 用户运行 docker,你需要把你自己添加进 docker 用户组,使用如下命令:

sudo usermod -a -G docker $USER

登出,然后再登入,以使组改变生效
这个时候,你应该可以以一个非特权用户运行 docker 命令了。

四、使用国内源

1、安装DAO

curl -sSL https://get.daocloud.io/daomonit/install.sh | sh -s 6d3f36d42ae3f3d4237943c65c8f3e5446e49a71

2、使用dao命令

dao pull ubuntu

看起来像这样:

➜  ~  dao pull ubuntu
Dao From DaoCloud
Initializing, Please wait a minute
Using default tag: latest
Pulling repository daocloud.io/daocloud/daocloud-toolset
aa5dc2eecd4a: Download complete
status: Image is up to date for daocloud.io/daocloud/daocloud-toolset:latest
daocloud.io/daocloud/daocloud-toolset: this image was pulled from a legacy registry.  Important: This registry version will not be supported in Future versions of docker.
Inital Success


# ----------------------------------------------------------------------------
# DaoCloud ToolBox for Docker
#
# DaoCloud, Inc. (c) 2015
#
# Fastest way to pull image from Docker Registry
# ----------------------------------------------------------------------------

Pulling repository ubuntu
Pulling ubuntu image metadata
Pulling ubuntu:latest tag metadata
0105f98ced6d: Load layer complete
66395c31eb82: Load layer complete
002fa881DF8a: Load layer complete
a005e6b7dd01: Load layer complete
Loading image to docker ...

** Pull ubuntu success. **
You can find it with 'docker images ubuntu'

其他的可以参考脚本宝典之前发布的文章

脚本宝典总结

以上是脚本宝典为你收集整理的在CentOS、Fedora系统中使用Docker的方法全部内容,希望文章能够帮你解决在CentOS、Fedora系统中使用Docker的方法所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。