关于apache:Docker-实战之-CentOS7-系统环境配置

37次阅读

共计 4431 个字符,预计需要花费 12 分钟才能阅读完成。

本文档具体介绍 Docker 实战之 CentOS7 零碎环境配置,为前期装置 Docker 做筹备。

0 优化环境

间接复制以下代码,优化环境,如果执行了一下代码,那么接下来的 1 和 2 步骤能够不必再操作了。

sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/’ /etc/selinux/config &> /dev/null
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
iptables -F
systemctl stop NetworkManager &> /dev/null
systemctl disable NetworkManager &> /dev/null

1 敞开 SELinux 和防火墙

[root@Docker]# vim /etc/selinux/config
SELINUX=disabled
[root@Docker]# setenforce 0
[root@Docker]# getenforce
Permissive

2 敞开 Firewalld 和 iptables

[root@Docker]# systemctl stop firewalld
[root@Docker]# systemctl disable firewalld
[root@Docker]# systemctl status firewalld
[root@Docker]# iptables -F

3 配置 yum 源

[root@Docker]# mv /etc/yum.repos.d/Cent* /tmp
[root@Docker]# vim /etc/yum.repos.d/CentOS7.repo
[aliyun-os]
name=aliyun-os
baseurl=https://mirrors.aliyun.com/ce…
enabled=1
gpgcheck=0

[aliyun-epel]
name=aliyun-epel
baseurl=https://mirrors.aliyun.com/ep…
enabled=1
gpgcheck=0

[aliyun-extra]
name=aliyun-extra
baseurl=https://mirrors.aliyun.com/ce…
enabled=1
gpgcheck=0

[root@Docker]# yum clean all && yum makecache

增加 epel 源

[root@Docker]# yum install epel-release -y

增加 docker-ce 源

[root@Docker]# yum install -y yum-utils
[root@Docker]# yum-config-manager –add-repo http://mirrors.aliyun.com/doc…
[root@Docker]# cat /etc/yum.repos.d/docker-ce.repo 
[docker-ce-stable]
name=Docker CE Stable – $basearch
baseurl=https://mirrors.aliyun.com/do…$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/do…

[docker-ce-stable-debuginfo]
name=Docker CE Stable – Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/do…$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/do…

[docker-ce-stable-source]
name=Docker CE Stable – Sources
baseurl=https://mirrors.aliyun.com/do…
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/do…

[docker-ce-edge]
name=Docker CE Edge – $basearch
baseurl=https://mirrors.aliyun.com/do…$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/do…

[docker-ce-edge-debuginfo]
name=Docker CE Edge – Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/do…$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/do…

[docker-ce-edge-source]
name=Docker CE Edge – Sources
baseurl=https://mirrors.aliyun.com/do…
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/do…

[docker-ce-test]
name=Docker CE Test – $basearch
baseurl=https://mirrors.aliyun.com/do…$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/do…

[docker-ce-test-debuginfo]
name=Docker CE Test – Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/do…$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/do…

[docker-ce-test-source]
name=Docker CE Test – Sources
baseurl=https://mirrors.aliyun.com/do…
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/do…

[docker-ce-nightly]
name=Docker CE Nightly – $basearch
baseurl=https://mirrors.aliyun.com/do…$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/do…

[docker-ce-nightly-debuginfo]
name=Docker CE Nightly – Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/do…$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/do…

[docker-ce-nightly-source]
name=Docker CE Nightly – Sources
baseurl=https://mirrors.aliyun.com/do…
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/do…

[root@Docker]# yum clean all && yum makecache

4 配置 hostname

[root@Docker]# vim /etc/hostname
Docker

5 配置 /etc/hosts

[root@Docker]# vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhostlocaldomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.7 Docker

[root@Docker]# ping $HOSTNAME

6 同步工夫

[root@Docker]# find / -name Shanghai
/usr/share/zoneinfo/Asia/Shanghai
/usr/share/zoneinfo/posix/Asia/Shanghai
/usr/share/zoneinfo/right/Asia/Shanghai
[root@Docker]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
cp: overwrite‘/etc/localtime’? y
[root@Docker]# yum install -y ntp ntpdate
[root@Docker]# systemctl enable ntpd
[root@Docker]# systemctl start ntpd
[root@Docker]# ntpdate cn.pool.ntp.org
[root@Docker]# ntpdate 0.rhel.pool.ntp.org

手动改工夫:date -s “2019-09-09 19:19”

7 配置 pip 镜像源,不便疾速下载 python 库(这一步很重要)

[root@Docker]# mkdir /.pip
[root@Docker]# vim  /.pip/pip.conf  #写入下以内容
[global]
index-url = http://mirrors.aliyun.com/pyp…
[install]
trusted-host=mirrors.aliyun.com

8  配置网卡信息

[root@Docker]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.10.7
GATEWAY=192.168.10.2
NETMASK=255.255.255.0

总结

以上的操作就是 CentOS7 零碎环境配置的过程,为装置 Docker 做好筹备。想看怎么装置 Docker 的敌人请继续关注我的文章,心愿我的文章能给大家带来帮忙。

正文完
 0