skip to Main Content

I have Node JS application

docker-compose.yml

version: '3'
  services:  
    app:
      build:
        context: .
        dockerfile: Dockerfile
      command: 'yarn nuxt'
      ports:
       - 3000:3000
      volumes:
       - '.:/app'

Dockerfile

FROM node:15

RUN apt-get update 
    && apt-get install -y curl

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - 
    && echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list 
    && apt-get update 
    && apt-get install -y yarn

WORKDIR /app

After running $ docker-compose up -d application starts and inside container it’s accessible

$ docker-compose exec admin sh -c 'curl -i localhost:3000'
// 200 OK

But outside of container it’s doesnt work. For example in chrome ERR_SOCKET_NOT_CONNECTED

2

Answers


  1. Chosen as BEST ANSWER

    Adding this to app service solves problem in docker-compose.yml

    environment:
        HOST: 0.0.0.0
    

    Thanks to Marc Mintel article Development setup with Nuxt, Node and Docker


  2. did you try to add

    published: 3000
    
    

    you can read more here – https://docs.docker.com/compose/compose-file/compose-file-v3/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search