修改静态IP

    1. cd /etc/sysconfig/network-scripts/
    2. vim ifcfg-ens33

    文件内容:

    1. TYPE="Ethernet"
    2. PROXY_METHOD="none"
    3. BROWSER_ONLY="no"
    4. BOOTPROTO="static"
    5. DEFROUTE="yes"
    6. IPV4_FAILURE_FATAL="no"
    7. IPV6INIT="yes"
    8. IPV6_AUTOCONF="yes"
    9. IPV6_DEFROUTE="yes"
    10. IPV6_FAILURE_FATAL="no"
    11. IPV6_ADDR_GEN_MODE="stable-privacy"
    12. NAME="ens33"
    13. UUID="78d66a02-f2cc-49d6-9357-3e2cf39b9484"
    14. DEVICE="ens33"
    15. ONBOOT="yes"
    16. # 将190改为你的网关号
    17. IPADDR="192.168.190.151" #ip地址
    18. GATEWAY="192.168.190.2" #网关(网络关卡)
    19. NETMASK="255.255.255.0" #子网掩码
    20. DNS1="192.168.190.2"
    21. IPADDR="192.168.163.140" #ip地址
    22. GATEWAY="192.168.163.2" #网关(网络关卡)
    23. NETMASK="255.255.255.0" #子网掩码
    24. DNS1="192.168.163.2"
    systemctl restart network
    systemctl stop firewalld
    systemctl disable firewalld
    

    IPV4开启

    vi /etc/sysctl.conf
    net.ipv4.ip_forward=1  #最下方添加这段代码
    #重启network服务
    systemctl restart network && systemctl restart docker
    #查看是否修改成功 (备注:返回1,就是成功)
    [root@docker-node2 ~]# sysctl net.ipv4.ip_forward
    net.ipv4.ip_forward = 1
    
    version: '3'
    services:
      web:
        build: .
        ports:
          - "8080:8080"
        depends_on:
          - db
          - redis
      # redis服务
      redis:
        image: redis
      # mysql服务
      db:
        image: mysql:5.7