Reputation: 67
I'm trying to run a container described by the following Dockerfile:
FROM node:11.4.0
RUN npm install -g sh
RUN npm install -g json-server
WORKDIR /data
VOLUME /data
COPY db.json /data
CMD json-server --watch db.json --port 3001
and specifying the listening port by running:
docker run -it -p 3001:3001 abelalejandro/json-server:final
The container seems to be running fine and json-server is telling me it is serving my requests on port 3001 yet I can't get any joy when browsing http://localhost:3001
Am I missing something on publishing/exposing ports?
Upvotes: 0
Views: 827
Reputation: 705
It is binding to localhost
instead of 0.0.0.0
(any host).
You can change that by setting:
CMD json-server --watch db.json --host 0.0.0.0 --port 3001
I'm assuming you are using https://github.com/typicode/json-server.
Upvotes: 7