Reputation: 617
I have this docker-compose file:
version: '2'
services:
web:
build: .
container_name: Fila
ports:
- 8000:8000
- 9000:9000
And this dockerfile:
FROM phpdockerio/php73-fpm:latest
WORKDIR /var/www
COPY . /var/www/atendimento
WORKDIR /var/www/atendimento
RUN composer install
RUN mv .env.example .env
#RUN node index.js &
RUN php artisan key:generate
CMD [ "php", "artisan", "serve" ]
After run "docker-compose up" and execute without error,
when I tried to acess localhost:8000 in my host on navigator, i get "the connection has been reset"
inside the docker i test with "wget localhost:8000" and get the correct site. but in the host no.
Someone can help-me?
Upvotes: 1
Views: 1647
Reputation: 432
I think your Dockerfile should add EXPOSE
Let add a line below into Dockerfile:
EXPOSE 8000 9000
Upvotes: 0
Reputation: 305
You need to bind the host to 0.0.0.0 on the aritsan command using the --host flag.
CMD [ "php", "artisan", "serve", "--host", "0.0.0.0"]
Why it didn't worked?
Without setting the host, artisan will bind the server to the container localhost. The container localhost and your machine localhost are different.
Setting 0.0.0.0 will bind the server to all interfaces, including the host machine interface making it available at localhost:8000.
Upvotes: 3