I have a Windows 10 Home on my computer with WSL2. In WSL I run Docker with this docker-compose.yml
file:
version: "3"
services:
httpd:
image: 'nginx:stable-alpine'
ports:
- '80:80'
volumes:
- ./:/var/www/html
- ./.docker-config/nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
- php
- mysql
networks:
- mynet
php:
build:
context: ./.docker-config/dockerfiles
dockerfile: php.dockerfile
volumes:
- ./:/var/www/html:delegated
networks:
- mynet
networks:
mynet:
driver: bridge
In ./.docker-config/nginx/nginx.conf
I have this configuration:
server {
listen 80;
index index.php index.html;
server_name localhost;
root /var/www/html/public;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
I start my Docker containers with this command:
docker-compose up -d
I add my custom domain to the hosts
file in Windows with WSL2 current IP address.
In a Power Shell I try to ping my domain and it's responding, so I think the hosts config is good.
But if I try to reach my domain in a browser, is't not responding. The error message is ERR_CONNECTION_TIMED_OUT
.
The wierd part is yesterday it was worked, and nothing changed in config files. The computer (and of course the WSL2 and the Docker) was shutted down and booted up today.
Any idea what's happend here and how can I avoid this situation in the future?
UPDATE
I changed my network's name, restart docker and everything is work's fine. But I don't understand what's happend here. Still I waiting answer to understand the reason of this issue.
Thanks!