title: Running docker container not accessible from host (localhost:8081)
body: <p>Using Ubuntu.</p>
  
  <p>Based on this guide:</p>
  
  <p><a href="https://www.freecodecamp.org/news/how-to-use-routing-in-vue-js-to-create-a-better-user-experience-98d225bbcdd9/" rel="noreferrer">https://www.freecodecamp.org/news/how-to-use-routing-in-vue-js-to-create-a-better-user-experience-98d225bbcdd9/</a></p>
  
  <p>I have created a minimal vuejs project with below project structure:</p>
  
  <p><a href="https://github.com/dev-samples/samples/tree/master/vuejs-001" rel="noreferrer">https://github.com/dev-samples/samples/tree/master/vuejs-001</a></p>
  
  <pre><code>frontend-router/
    build/
    config/
    src/
    static/
    test/
    build.sh
    Dockerfile.dev
    package-lock.json
    package.json
  </code></pre>
  
  <p>Where:</p>
  
  <p><strong>Dockerfile.dev</strong></p>
  
  <pre><code>FROM node:10
  RUN apt install curl
  RUN mkdir /app
  
  # add `/app/node_modules/.bin` to $PATH
  ENV PATH /app/node_modules/.bin:$PATH
  
  # install and cache app dependencies
  COPY package.json /app/package.json
  
  # make the 'app' folder the current working directory before running npm install
  WORKDIR /app
  
  RUN npm install
  CMD [ "npm", "run", "dev" ]
  </code></pre>
  
  <p>I am building the image and running the container from that image with:</p>
  
  <pre><code>docker build -t frontend-router-image -f Dockerfile.dev .
  docker rm -f frontend-router-container
  
  docker run -it -p 8081:8080 -v ${PWD}:/app/ -v /app/node_modules --name frontend-router-container frontend-router-image
  </code></pre>
  
  <p>which gives:</p>
  
  <pre><code>DONE  Compiled successfully in 1738ms                                                                                                                                                    3:49:45 PM
  
   I  Your application is running here: http://localhost:8080
  </code></pre>
  
  <p>Since I add <code>-p 8081:8080</code> to docker run command I would expect that I can access the application from my host browser on:</p>
  
  <p><a href="http://localhost:8081/" rel="noreferrer">http://localhost:8081/</a></p>
  
  <p>but it just gives below error:</p>
  
  <p><a href="https://i.stack.imgur.com/M0NJQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/M0NJQ.png" alt="enter image description here"></a></p>
  
  <p>I works fine when I run it with vanilla npm from my host. But why can't I access the application when its run from inside a docker container?</p>
  
  <p>Source code here:</p>
  
  <p><a href="https://github.com/dev-samples/samples/tree/master/vuejs-001" rel="noreferrer">https://github.com/dev-samples/samples/tree/master/vuejs-001</a></p>
  
  <p>As suggested below I have tried:</p>
  
  <pre><code>$ docker ps
  CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                    NAMES
  e011fb9e39e8        frontend-router-image   "docker-entrypoint.s…"   12 seconds ago      Up 9 seconds        0.0.0.0:8081-&gt;8080/tcp   frontend-router-container
  
  $ docker run -it --rm --net container:frontend-router-container nicolaka/netshoot ss -lnt
  State     Recv-Q    Send-Q       Local Address:Port        Peer Address:Port    
  LISTEN    0         128              127.0.0.1:8080             0.0.0.0:*       
  </code></pre>
  
  <p>For comparison this project works fine:</p>
  
  <p><a href="https://github.com/dev-samples/samples/tree/master/vuejs-002" rel="noreferrer">https://github.com/dev-samples/samples/tree/master/vuejs-002</a></p>
  
  <p>Meaning that when I run a container I can access the web application on my host browser on <code>localhost:8081</code></p>