title: Connect to a Nest.js server inside a docker container
body: <p>I'm trying to create a container for a Nest.js server. For now,I only have the basic version of the server that creates automatically when you create a Nest project. I tried some things in Dockerfile and docker-compose, but when I start the container and go to browser to <code>localhost:3042</code> it says the page isn't working, but it should GET an object.</p>
  
  <p>So right now, my Dockerfile looks like this:</p>
  
  <pre><code>FROM node:10
  
  WORKDIR /microservices
  
  COPY package*.json ./
  COPY tsconfig.json tsconfig.json
  COPY src src
  RUN ["npm","install","global","@nestjs/cli"]
  RUN ["npm", "install"]
  
  EXPOSE 3042
  
  ENTRYPOINT ["npm","run","start"]
  </code></pre>
  
  <p>And my docker-compose.yaml looks like this:</p>
  
  <pre><code>version: "3.2"
  services:
    server:
      container_name: server
      hostname: localhost
      build: ./
      ports:
      - "3042:3042"
  </code></pre>
  
  <p>I run <code>docker-compose up</code>, go to browser and it doesn't work.</p>
  
  <p>The output of the <code>docker-compose up</code> command is:</p>
  
  <pre><code>server      | [Nest] 18   - 07/12/2019, 1:44 PM   [NestFactory] Starting Nest application...
  server      | [Nest] 18   - 07/12/2019, 1:44 PM   [InstanceLoader] AppModule dependencies initialized +26ms
  server      | [Nest] 18   - 07/12/2019, 1:44 PM   [RoutesResolver] AppController {/}: +10ms
  server      | [Nest] 18   - 07/12/2019, 1:44 PM   [RouterExplorer] Mapped {/, GET} route +7ms
  server      | [Nest] 18   - 07/12/2019, 1:44 PM   [NestApplication] Nest application successfully started +5ms
  </code></pre>
  
  <p>So it seems like inside something is going on and the app starts successfully.</p>
  
  <p>I looked on some examples, the one from their documentation where python is used and another example with <code>Express.js</code>, but didn't help me.</p>