L
L
lemonlimelike2020-11-08 23:56:54
PHP
lemonlimelike, 2020-11-08 23:56:54

Why can't I run the application through docker?

Hello! I'm trying to run a symfony application using docker. I downloaded the symfony application using composer'a api

composer create-project symfony/skeleton my_project_name
. Created in the installed project Dockerfile. Filled it with content like this
FROM php:7.4-cli

ADD . /opt/symfony
WORKDIR /opt/symfony

EXPOSE 8080

CMD ["php", "-S", "localhost:8080", "-t", "public/"]


That is, in fact, port 8080 opens and I php -S localhost:8080 -t public/start the server with the command.
Then I build this project sudo docker build -t name/symfony .
And run it sudo docker run -p 8080:8080 name/symfony
I get this:
5fa85b7491a66975120595.png

And I try to go to localhost:8080 from the browser, but I get this
5fa859fd4859a759990481.png

How can I fix this? Why can't I access the app?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
krundetz, 2020-11-09
@lemonlimelike

And will you also run it in production on the server built into the php?
Since you are already using docker, use the php-fpm 7.4 application server, and nginx 1.19 as the web server. (Well, or try to reproduce the combination on which the application will work in production)
There will be fewer surprises later, because you will learn about them in the development process.
For docker-compose, the config will look something like this:

version: '2'
services:
    nginx:
        image: nginx:1.19
        ports:
              - "80:80"
        volumes:
            - ./path_to_nginx_config:/etc/nginx/conf.d
            - ./path_to_app:/var/www/app
        links:
            - php
    php:
        image: php:7.4-fpm
        ports:
            - "9000:9000"
        volumes:
            - ./path_to_app:/var/www/app

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question