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
Adding this to
app
service solves problem in docker-compose.ymlThanks to Marc Mintel article Development setup with Nuxt, Node and Docker
did you try to add
you can read more here – https://docs.docker.com/compose/compose-file/compose-file-v3/