龙空技术网

Docker 实战之 CentOS7 系统环境配置

Linux速推文章 198

前言:

此刻咱们对“centos应用环境”大体比较讲究,我们都需要了解一些“centos应用环境”的相关文章。那么小编也在网络上汇集了一些关于“centos应用环境””的相关内容,希望各位老铁们能喜欢,朋友们一起来学习一下吧!

本文档详细介绍 Docker 实战之 CentOS7 系统环境配置,为后期安装 Docker 做准备。

0 优化环境

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

sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config &> /dev/nullsetenforce 0systemctl stop firewalldsystemctl disable firewalldiptables -Fsystemctl stop NetworkManager &> /dev/nullsystemctl disable NetworkManager &> /dev/null

1 关闭SELinux和防火墙

[root@Docker ]# vim /etc/selinux/configSELINUX=disabled[root@Docker ]# setenforce 0[root@Docker ]# getenforcePermissive

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-osbaseurl=[aliyun-epel]name=aliyun-epelbaseurl=[aliyun-extra]name=aliyun-extrabaseurl=[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 [root@Docker ]# cat /etc/yum.repos.d/docker-ce.repo [docker-ce-stable]name=Docker CE Stable - $basearchbaseurl=[docker-ce-stable-debuginfo]name=Docker CE Stable - Debuginfo $basearchbaseurl=[docker-ce-stable-source]name=Docker CE Stable - Sourcesbaseurl=[docker-ce-edge]name=Docker CE Edge - $basearchbaseurl=[docker-ce-edge-debuginfo]name=Docker CE Edge - Debuginfo $basearchbaseurl=[docker-ce-edge-source]name=Docker CE Edge - Sourcesbaseurl=[docker-ce-test]name=Docker CE Test - $basearchbaseurl=[docker-ce-test-debuginfo]name=Docker CE Test - Debuginfo $basearchbaseurl=[docker-ce-test-source]name=Docker CE Test - Sourcesbaseurl=[docker-ce-nightly]name=Docker CE Nightly - $basearchbaseurl=[docker-ce-nightly-debuginfo]name=Docker CE Nightly - Debuginfo $basearchbaseurl=[docker-ce-nightly-source]name=Docker CE Nightly - Sourcesbaseurl=[root@Docker ]# yum clean all && yum makecache

4 配置 hostname

[root@Docker ]# vim /etc/hostnameDocker

5 配置/etc/hosts

[root@Docker ]# vim /etc/hosts127.0.0.1   localhost localhost.localdomain localhost4 localhostlocaldomain4::1         localhost localhost.localdomain localhost6 localhost6.localdomain6192.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 = [install]trusted-host=mirrors.aliyun.com

8 配置网卡信息

[root@Docker ]# vim /etc/sysconfig/network-scripts/ifcfg-ens33 TYPE=EthernetPROXY_METHOD=noneBROWSER_ONLY=noBOOTPROTO=staticDEFROUTE=yesIPV4_FAILURE_FATAL=noNAME=ens33DEVICE=ens33ONBOOT=yesIPADDR=192.168.10.7GATEWAY=192.168.10.2NETMASK=255.255.255.0

总结

以上的操作就是 CentOS7 系统环境配置的过程,为安装 Docker 做好准备。想看怎么安装 Docker 的朋友请持续关注我的文章,希望我的文章能给大家带来帮助。

标签: #centos应用环境