Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot work CentOS, but Ubuntu work fine #52

Open
JmyW opened this issue Dec 1, 2020 · 3 comments
Open

Cannot work CentOS, but Ubuntu work fine #52

JmyW opened this issue Dec 1, 2020 · 3 comments

Comments

@JmyW
Copy link

JmyW commented Dec 1, 2020

I have tried both CentOS 8 and Ubuntu 20.10.
It's quite simple, just able to make it work perfectly in Ubuntu 20.10.
But same docker-compose.yml cannot work in CentOS 8. I have tried many time re-installation of CentOS. Unfortunately just failed.
The docker compose is well completed. But when I visit 127.0.0.1:8000, it just feedback "502 Bad Gateway". Access 127.0.0.1:8080 for PhpMyAdmin, it appear the query of host/account/password. When I input the host/account/password, it gives message " mysqli::real_connect(): (HY000/2002): No route to host".

I tested the Ubuntu and CentOS back and forth twice on "same" machine. The Ubuntu can work everytime. The CentOS failed everytime.

@JmyW
Copy link
Author

JmyW commented Dec 2, 2020

Anyone know how to resolve it? thanks in advance.

@bclincy
Copy link

bclincy commented Dec 30, 2020

Looks like CentOS Docker local networking working. You can add your own private network and use IP addresses.
You can use the IP vs the [https://docs.docker.com/config/containers/container-networking/](docker DNS)
In your PDO string you can replace it with the IP

networks:
  LEMP:
    ipam:
      driver: default
      config:
        - subnet: 172.21.0.0/16
  services:
    web:
        image: nginx:alpine
        volumes:
            - "./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf"
            - "./etc/nginx/nginx_custom.conf:/etc/nginx/conf.d/nginx_custom.conf"
            - "./etc/ssl:/etc/ssl"
            - "./web:/var/www/html"
            - "./etc/nginx/default.template.conf:/etc/nginx/conf.d/default.template"
         networks:
             LEMP:
                 ipv4_address: 172.21.0.11
        env_file:
            - ".env"
        ports:
            - "8000:80"
            - "3000:443"
        environment:
            - NGINX_HOST=${NGINX_HOST}
        command: /bin/sh -c "envsubst '$$NGINX_HOST' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
        restart: always
        depends_on:
            - php
            - mysqldb
    php:
        image: nanoninja/php-fpm:${PHP_VERSION}
        restart: always
        environment:
            - NGINX_HOST=${NGINX_HOST}
            - MYSQL_DATABASE=${MYSQL_DATABASE}
            - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
            - MYSQL_USER=${MYSQL_USER}
            - MYSQL_PASSWORD=${MYSQL_PASSWORD}
            - MYSQL_HOST=${MYSQL_HOST}
        volumes:
            - "./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini"
            - "./web:/var/www/html"
         networks:
             LEMP:
                 ipv4_address: 172.21.0.9
    composer:
        image: "composer"
        volumes:
            - "./web/app:/app"
        command: ["composer", "install"]
    myadmin:
        image: phpmyadmin/phpmyadmin
        container_name: phpmyadmin
        ports:
            - "8080:80"
        environment:
            - PMA_ARBITRARY=1
            - PMA_HOST=${MYSQL_HOST}
        restart: always
        depends_on:
            - mysqldb
         networks:
             LEMP:
                 ipv4_address: 172.21.0.10
    mysqldb:
        image: mysql:${MYSQL_VERSION}
        container_name: ${MYSQL_HOST}
        restart: always
        env_file:
            - ".env"
        environment:
            - MYSQL_DATABASE=${MYSQL_DATABASE}
            - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
            - MYSQL_USER=${MYSQL_USER}
            - MYSQL_PASSWORD=${MYSQL_PASSWORD}
        ports:
            - "8989:3306"
        volumes:
            - "./data/db/mysql:/var/lib/mysql"
            - ./data/sql-scripts/:/docker-entrypoint-initdb.d/ # sql file for loading initial data
         networks:
             LEMP:
                 ipv4_address: 172.21.0.7

@JmyW
Copy link
Author

JmyW commented Jan 5, 2021

@bclincy Thanks for guidance. My server was a new creation, so I could decide which one I can install with less issue. Since the problem I posted before, therefore I decided to adopt the Debian Linux. And it works fine like Ubuntu. And I'm sorry I won't be back CentOS for further try. I leave this to comment by others if someone check it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants