Octo
Octo

Reputation: 103

Can't connect to Node inside Docker image

I've created an image using this Docker file...

FROM node:8

# Create application directory
WORKDIR /usr/src/app

# Install application dependencies
# By only copying the package.json file here, we take advantage of cached Docker layers
COPY package.json ./
RUN npm install
# This will install dev dependencies as well. 
# If dev dependencies have been set, use --only-production when deploying to production

# Bundle app source code
COPY . .

EXPOSE 3000

CMD ["node", "server.js"]

But when I run it using $ docker run -d --rm -p 3000:3000 62 I can't cUrl the API running inside the container from the Docker host (OS X) using curl http://localhost:3000/About

If I exec into the container I get a valid response from the API via cUrl. Looks like a Linux firewall in the container but I don't see one running.

any ideas?

Upvotes: 5

Views: 1738

Answers (1)

Uku Loskit
Uku Loskit

Reputation: 42040

Your node server is most likely not listening on all interfaces, make sure it binds to 0.0.0.0 instead of 127.0.0.1

Upvotes: 9

Related Questions