当前环境:centos7
1.参考docker官方文档安装docker:https://docs.docker.com/engine/installation/linux/centos/
[[email protected] ~]# yum update #更新yum源 [[email protected] ~]# tee /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 #添加yum源 [[email protected] ~]# yum install docker-engine #安装docker [[email protected] ~]# systemctl enable docker.service #设置docker服务开机自动启动 [[email protected] ~]# systemctl start docker #启动docker #以上内容摘抄自docker官方文档
安装完毕后查看当前版本:
[[email protected] ~]# docker version
docker安装完毕
2.给docker设置用户和组
[[email protected] ~]# useradd -g docker docker #创建docker用户 [[email protected] ~]# usermod -aG docker docker #将docker用户添加到docker用户组
3.设置docker开机自启动
[[email protected] ~]# systemctl enable docker.service
ps:
#启动docker [[email protected] ~]# systemctl start docker #停止 [[email protected] ~]# systemctl stop docker #重启 [[email protected] ~]# systemctl restart docker #查看状态 [[email protected] ~]# systemctl status docker
时间: 2025-01-31 09:39:58