简体   繁体   中英

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?

您的节点服务器很可能没有在所有接口上侦听,请确保它绑定到0.0.0.0而不是127.0.0.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM