Docker容器

CentOS 7 安装 docker

本文主要是介绍CentOS 7 安装 docker,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

配置环境

--------------------------------------------------------------------------------------------------------- ##
关闭防火墙和selinux
[root@manager ~]# systemctl stop firewalld && systemctl disable firewalld
[root@manager ~]# sed -i ‘/^SELINUX=/s/enforcing/disabled/’ /etc/selinux/config
[root@manager ~]# setenforce 0
--------------------------------------------------------------------------------------------------------- ##
设置时间同步
[root@manager ~]# timedatectl set-timezone Asia/Shanghai # 可修改时区为上海+08时区
[root@manager ~]# timedatectl # 获取系统时间和时区

[root@manager ~]# yum install ntp -y # 安装ntp时间服务器
[root@manager ~]# sed -i ‘s/server 0.centos.pool.ntp.org iburst/server ntp1.aliyun.com iburst/’ /etc/ntp.conf # 使用aliyun NTP服务
[root@manager ~]# sed -i ‘/1.centos.pool.ntp.org/s/^/#/’ /etc/ntp.conf
[root@manager ~]# sed -i ‘/2.centos.pool.ntp.org/s/^/#/’ /etc/ntp.conf
[root@manager ~]# sed -i ‘/3.centos.pool.ntp.org/s/^/#/’ /etc/ntp.conf

[root@manager ~]# systemctl start ntpd && systemctl enable ntpd # 启动ntp时间服务并设置开机启动
--------------------------------------------------------------------------------------------------------- ##
安装常用软件:
[root@manager ~]# yum -y install vim wget net-tools lrzsz telnet bind-utils bash-completion

安装 docker

#删除旧版docker
[root@localhostsshd]# yum remove docker
docker-client
docker-client-latest
docker-common
docker-latest
docker-latest-logrotate
docker-logrotate
docker-engine
#下载 yum工具包
[root@localhostsshd]# yum install -y yum-utils
#设置docker仓库
[root@localhostsshd]# yum-config-manager
–add-repo
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#安装docker
[root@localhostsshd]# yum -y install docker-ce docker-ce-cli containerd.io
#启动docker并设置开机自启
[root@localhostsshd]# systemctl start docker && systemctl enable docker
#查看安装的docker版本
[root@localhostsshd]# docker version
#运行hello-world镜像
[root@localhostsshd]# docker run hello-world

这篇关于CentOS 7 安装 docker的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!