title: How do I make my VS Code dev/remote container port accessible to localhost?
body: <p>I have a GraphQL application that run inside a container. If I run <code>docker compose build</code> followed by <code>docker compose up</code> I can connect to it via <code>localhost:9999/graphql</code>. Inside the dockerfile the port forwarding is <code>9999:80</code>. When I run the <code>docker container ls</code> command I can see the ports are forewarded as expected.
  I'd like to running this in a VS Code remote container. Selecting <code>Open folder in remote container</code> gives me the option of selecting either the dockerfile or the docker-compose file to build the container. I've tried both options and neither allows me to access the GraphQL playground from localhost. Running from docker-compose I can see that the ports appear to be forwarded in the same manner as if I ran <code>docker compose up</code> but I can't access the site.
  Where am I going wrong?</p>
  <p>Update: If I run <code>docker compose up</code> on the container that is built by vs code, I can connect to localhost and the graphql playground.</p>
  <pre><code>FROM docker.removed.local/node
  MAINTAINER removed
  
  WORKDIR /opt/app
  
  COPY package.json /opt/app/package.json
  COPY package-lock.json /opt/app/package-lock.json
  COPY .npmrc /opt/app/.npmrc
  RUN echo &quot;nameserver 192.168.11.1&quot; &gt; /etc/resolv.conf &amp;&amp; npm ci
  RUN mkdir -p /opt/app/logs
  
  # Setup a path for using local npm packages
  RUN mkdir -p /opt/node_modules
  
  ENV PATH /opt/node_modules/.bin:$PATH
  
  COPY ./ /opt/app
  EXPOSE 80
  
  ENV NODE_PATH /opt:/opt/app:$NODE_PATH
  ARG NODE_ENV
  
  VOLUME [&quot;/opt/app&quot;]
  
  CMD [&quot;forever&quot;, &quot;-o&quot;, &quot;/opt/app/logs/logs.log&quot;, &quot;-e&quot;, &quot;/opt/app/logs/error.log&quot;, &quot;-a&quot;, &quot;server.js&quot;]
  
  version: '3.5'
  services:
    server:
        build: .
        container_name: removed-data-graph
        command: nodemon --ignore 'public/*' --legacy-watch src/server.js
        image: docker.removed.local/removed-data-graph:local
        ports:
            - &quot;9999:80&quot;
        volumes:
            - .:/opt/app
            - /opt/app/node_modules/
              #- ${LOCAL_PACKAGE_DIR}:/opt/node_modules
        depends_on:
            - redis
        networks:
            - company-network
        environment:
            - NODE_ENV=dev
    redis:
        container_name: redis
        image: redis
        networks:
            - company-network
        ports:
            - &quot;6379:6379&quot;
  networks:
      company-network:
          name: company-network
  </code></pre>