首页 > 代码库 > 安装部署docker环境

安装部署docker环境

当前环境:centos7

1.参考docker官方文档安装docker:https://docs.docker.com/engine/installation/linux/centos/

[root@catchtouch ~]# yum update #更新yum源

[root@catchtouch ~]# 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源

[root@catchtouch ~]# yum install docker-engine #安装docker

[root@catchtouch ~]# systemctl enable docker.service #设置docker服务开机自动启动

[root@catchtouch ~]# systemctl start docker #启动docker

#以上内容摘抄自docker官方文档

 

安装完毕后查看当前版本:

[root@catchtouch ~]# docker version

技术分享

docker安装完毕

2.给docker设置用户和组

[root@catchtouch ~]# useradd -g docker docker  #创建docker用户
[root@catchtouch ~]# usermod -aG docker docker  #将docker用户添加到docker用户组

3.设置docker开机自启动

[root@catchtouch ~]# systemctl enable docker.service

ps:

#启动docker
[root@catchtouch ~]# systemctl start docker
#停止
[root@catchtouch ~]# systemctl stop docker
#重启
[root@catchtouch ~]# systemctl restart docker
#查看状态
[root@catchtouch ~]# systemctl status docker

 

安装部署docker环境