Access index.php from docker

I’ve created a docker with a database and a php server but I’m failing accessing the php file from the server.

For testing purpose I’m currently having 2 index.php in my test app ./index.php and ./app/index.php

This is my docker-compose.yml

version: '3'
services:
  symfony:
    build:
      context: .
      dockerfile: docker/Dockerfile
    image: project-manager
    ports:
      - 80:80
  db:
    image: mysql
    ports:
      - 3306:3306
    volumes:
      - "./.data/db:/var/lib/mysql"
    environment:
      MYSQL_ROOT_PASSWORD: root

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    ports:
      - "8080:80"
    links:
      - db

This is the php dockerfile

FROM php:7.4-fpm

# Install Composer
COPY --from=composer /usr/bin/composer /usr/bin/composer

# Copy all our files in the docker root
COPY . /

docker ps

CONTAINER ID        IMAGE                   COMMAND                  CREATED              STATUS              PORTS                               NAMES
f80a16af8336        project-manager         "docker-php-entrypoi…"   About a minute ago   Up About a minute   0.0.0.0:80->80/tcp, 9000/tcp        project-manager_symfony_1
d97688010adf        phpmyadmin/phpmyadmin   "/docker-entrypoint.…"   9 minutes ago        Up 9 minutes        0.0.0.0:8080->80/tcp                project-manager_phpmyadmin_1
55781c004031        mysql                   "docker-entrypoint.s…"   9 minutes ago        Up 9 minutes        0.0.0.0:3306->3306/tcp, 33060/tcp   project-manager_db_1

In my /etc/hosts

#Project Manager
127.0.0.1 project-manager.local

I can successfully access to the phpmyadmin using project-manager.local:8080

But if I try the simple project-manager.local/ or project-manager.local/index
I’ve got an empty response.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *