Answers: <p>I’m glad my comment helped. I read the <a href="https://docs.docker.com/docker-for-windows/networking/" rel="nofollow noreferrer">article</a> OP mentioned in his answer and reread his question and I think the issue isn’t using <code>-p</code> instead of <code>—publish</code> as the two work the same, but specifying <code>--network host</code>. 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.</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-09-07T10:33:05.773Z
Answers: Oh yeah, i completely forgot that! I also removed `--netowrk host`. Probably this was the root of the problems.
Answers: Cowboy_Patrick
Answers: CC BY-SA 4.0
Answers: 2020-09-06T09:46:39.327Z
Answers: 2020-09-06T09:46:39.327Z
Answers: Konrad Botor
Answers: <p>The comment from <a href="https://devops.stackexchange.com/users/12864/konrad-botor">Konrad Botor</a> 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 <a href="https://docs.docker.com/docker-for-windows/networking/" rel="nofollow noreferrer">here</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2020-09-06T05:19:55.220Z
Answers: 2020-09-06T05:19:55.220Z
Answers: Cowboy_Patrick
Body: <p>So I have this Dockerfile:</p>
  <pre><code>FROM openjdk:8u212-jre-alpine
  
  LABEL maintainer &quot;cowboy_patrick&quot;
  
  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
  </code></pre>
  <p>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.)</p>
  <p>When I execute it with</p>
  <blockquote>
  <p>docker run --network host -p 25565:25565 --name mcs mcserver</p>
  </blockquote>
  <p>I can see the following in the container-dashboard:
  <a href="https://i.sstatic.net/TMjuy.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TMjuy.png" alt="port forwarded" /></a></p>
  <p>For good measures you can see my console-output <a href="https://pastebin.pl/view/b13594bd" rel="nofollow noreferrer">here</a> but it's pretty standard. Just a minecraft-server that boots up.</p>
  <p>The only thing I don't understand is why the connection gets refused when I try to join localhost:25565:
  <a href="https://i.sstatic.net/vP5Ih.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/vP5Ih.png" alt="connection refused" /></a></p>
  <p>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).</p>
  
Comments: CC BY-SA 4.0
Comments: 2020-09-05T16:02:03.760Z
Comments: Are you using Docker for Windows or Docker Toolbox?
Comments: Konrad Botor
Comments: CC BY-SA 4.0
Comments: 2020-09-06T03:55:36.997Z
Comments: Right now for testing I use Docker for Windows. But later on i wanna deploy it in a linux production environment.
Comments: Cowboy_Patrick
Tags: <docker><dockerfile><networking>
Title: Minecraft docker-container refuses connection
UserDisplayName: Cowboy_Patrick
ThreadText: # Minecraft docker-container refuses connection
  
  (Asked by: username_0 on 2020-09-05)
  
  So I have this Dockerfile:
  
  ```
  FROM openjdk:8u212-jre-alpine
  
  LABEL maintainer "username_0"
  
  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](https://i.sstatic.net/TMjuy.png)](https://i.sstatic.net/TMjuy.png)
  
  For good measures you can see my console-output [here](https://pastebin.pl/view/b13594bd) 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](https://i.sstatic.net/vP5Ih.png)](https://i.sstatic.net/vP5Ih.png)
  
  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).
  
  **Tags:** docker, dockerfile, networking
  
  > **Comments:**
  > **username_1**: Are you using Docker for Windows or Docker Toolbox?  
  > **username_0**: Right now for testing I use Docker for Windows. But later on i wanna deploy it in a linux production environment.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-09-06. Score: 1 | Accepted answer
  
  I’m glad my comment helped. I read the [article](https://docs.docker.com/docker-for-windows/networking/) 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.
  
  > **Comments:**
  > **username_0**: Oh yeah, i completely forgot that! I also removed `--netowrk host`. Probably this was the root of the problems.  
  
  ---
  
  ### Answer by username_0 on 2020-09-06. Score: 0
  
  The comment from [username_1 username_1](https://devops.stackexchange.com/users/12864/username_1-username_1) 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](https://docs.docker.com/docker-for-windows/networking/)
  
  
  ---
  
  