Home > OS >  Can't access my app using local ip address when connected using Docker
Can't access my app using local ip address when connected using Docker

Time:12-13

I have my Codeigniter/PHP app set up in docker-compose. When I run localhost:8893 or 127.0.0.1:8893 it works perfectly. Now I want to share that address with my friends but when I access the same thing with my IP address 192.168.100.96:8893 it just keeps loading, with no response.

docker-compose.yaml

version: '3.7'
services:
  test-webserver:
    image: thecodingmachine/php:8.0-v4-apache-node16
    container_name: test-webserver
    working_dir: /var/www/html
    environment:
#      PHP_EXTENSIONS: apcu pdo_mysql opcache redis zip gd yaml exif xdebug
      PHP_EXTENSIONS: opcache redis zip gd yaml exif xdebug
      PHP_EXTENSION_GD: 1
      PHP_EXTENSION_MYSQLI: 1
      APACHE_DOCUMENT_ROOT: /var/www/html/
      APACHE_RUN_GROUP: www-data # use www-data user in container.. which is also used on most webservers for deployer
      APACHE_RUN_USER: www-data
      PHP_EXTENSION_XDEBUG: 1
    depends_on:
      - test-mariadb
    volumes:
      - ./:/var/www/html
      - ~/.ssh:/root/.ssh
    stdin_open: true
    tty: true
    expose:
      - "8893"
    ports:
      - "8893:80"
    networks:
      - test.network
  test-mariadb:
    container_name: test-mariadb
    image: mariadb:10.3.36
    networks:
      - test.network
    restart: always
    environment:
      - MARIADB_ROOT_PASSWORD=test123
    volumes:
      - ../mariadb:/var/lib/mysql
    expose:
      - "40000"
    ports:
      - "40000:3306"
  test-phpmyadmin:
    container_name: test-phpmyadmin
    image: phpmyadmin/phpmyadmin:latest
    networks:
      - test.network
    restart: always
    environment:
      - PMA_HOST=test-mariadb
      - PMA_PORT=3306
      - PMA_USER=root
      - PMA_PASSWORD=test123
      - UPLOAD_LIMIT=2048M
    expose:
      - "40001"
    ports:
      - "40001:80"
networks:
  test.network:
    driver: bridge
    name: test.network
    external: true

enter image description here

When I try to access the same with my IP address, it keeps loading.

enter image description here

You can confirm my local IP as well.

enter image description here

Here is my env config.

APP_DB_HOSTNAME=test-mariadb
APP_DB_USERNAME=root
APP_DB_PASSWORD=test123
APP_DB_NAME=my_test_db
APP_DB_PORT=3306
APP_DB_PREFIX=tbl

Can anyone figure out what I am missing here?

CodePudding user response:

Have you tried removing network block?

In my development environment I don't configure it and it's working fine.

If you only need to expose your app.... you don't need expose your DB.

CodePudding user response:

I checked again and it's working, in incognito mode, other browsers and my friend PC as well. Don't know what I did wrong in my current chrome browser. Question is completed now.

  • Related