Why Can’t I Access My Docker-Compose Container from the Host IP?

0
4
Asked By TechnoWizard42 On

I'm having trouble accessing my Docker container that's part of a bridge-type network. After some experimenting, I've lost the ability to connect to it. Currently, I can reach it using its internal IP (172.25.0.5), but trying to access it using 0.0.0.0 results in a "Connection timed out" error. I've ensured I exposed the port in my Docker Compose file and have attempted to recreate the network and restart the service without success. Here's the relevant section of my compose file:

```
networks:
mc_net:

services:
my-server:
build: ./my-server
container_name: my-server
networks:
- mc_net
user: "999:998"
ports:
- "25565:25565"
volumes:
- ./my-server:/app
restart: unless-stopped
tty: true
stdin_open: true
```

The Dockerfile used is as follows:
```
FROM openjdk:21-jdk-slim
WORKDIR /app
EXPOSE 25565
CMD ["./start.sh"]
```

I've run the command `docker compose up -d` and the output of `docker ps` shows the port is bound correctly. The server logs indicate that it starts successfully on port 25565. Testing connectivity from within another Docker container with the command `docker run --rm --network mc_net porscheinformatik/paping paping my-server -p 25565` returns successful pings. However, trying to ping using `./paping 0.0.0.0 -p 25565` from my local installation results in a timeout. Any ideas on how I can resolve this?

1 Answer

Answered By DockerDude88 On

It sounds like your container is set up right, but there might be a networking issue on your host. Have you tried accessing the server using `localhost` instead of `0.0.0.0`? Sometimes that can help depending on how your Docker is set up, especially on Mac or Windows.

TechnoWizard42 -

I did try that, but it timed out as well. I’ll check it again later and see if there are any changes.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.