0

So I have this Dockerfile:

FROM openjdk:8u212-jre-alpine

LABEL maintainer "cowboy_patrick"

RUN apk add --no-cache -U \
  openssl \
  imagemagick \
  lsof \
  su-exec \
  shadow \
  bash \
  curl iputils wget \
  git \
  jq \
  python \
  tzdata \
  rsync \
  nano \
  sudo \
  knock \
  ttf-dejavu
  
EXPOSE 25565 25565

COPY minecraft /root/minecraft
WORKDIR /root/minecraft


RUN chmod +x /root/minecraft/start_minecraft.sh

CMD /root/minecraft/start_minecraft.sh

This just copies an existing world into an alpine with java and executes some prewritten scripts, I had written for running it on a vps (doing automatic backups etc.)

When I execute it with

docker run --network host -p 25565:25565 --name mcs mcserver

I can see the following in the container-dashboard: port forwarded

For good measures you can see my console-output here but it's pretty standard. Just a minecraft-server that boots up.

The only thing I don't understand is why the connection gets refused when I try to join localhost:25565: connection refused

Does anyone have an idea on how I can allow this connection? And in extent allow connections from outside my machine (assuming that port-formwarding and everything works).

2
  • Are you using Docker for Windows or Docker Toolbox? Sep 5, 2020 at 16:02
  • Right now for testing I use Docker for Windows. But later on i wanna deploy it in a linux production environment. Sep 6, 2020 at 3:55

2 Answers 2

1

I’m glad my comment helped. I read the article OP mentioned in his answer and reread his question and I think the issue isn’t using -p instead of —publish as the two work the same, but specifying --network host. In Linux’s version of Docker daemon this prevents port publishing from working and since both Docker for Windows and Docker Toolbox use some sort of virtualization to run that version of Docker for Linux containers, I can only assume it has the same effect. The difference being that host in question is not Windows, but whatever Linux is running on top, so the container is completely unreachable.

1
  • Oh yeah, i completely forgot that! I also removed --netowrk host. Probably this was the root of the problems. Sep 7, 2020 at 10:33
0

The comment from Konrad Botor got me the idea that there are known issues on just the windows docker version. So I googled for it and in fact there are some differences! Using -P or --publish 25565:25565 worked for me. Read more here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.