1

I have an Angular application deployed in the container . If I log in to the container I can curl to the port 4200.

I have mapped to port 9001 to connect from my host .

But I can't curl from my host machine. What could be the issue? I think I should configure with docker bridge how to do that??

My Docker file:

FROM alpine:latest

#installing required pakages
RUN apk update
RUN apk fix
RUN apk add nodejs nodejs-npm apache2 curl yarn
RUN npm install -g @angular/cli
RUN npm install -g typescript
RUN mkdir -p /var/opt/angular

WORKDIR /opt

COPY . .

WORKDIR /opt/frontend

RUN npm install
RUN ng build
COPY start.sh /opt/frontend/start.sh
RUN chmod +x start.sh

EXPOSE 4200
CMD ["sh", "start.sh"]

Start-up script(start.sh):

#!/bin/bash

ng serve --host 0.0.0.0

While running the docker file I have specified. -p 9001:4200

  • please add your Dockerfile. – profesor79 Sep 2 '19 at 8:00
  • A suggestion for your dockerfile, merge RUN commands like RUN command1 && command2 to reduce the layers created and the image size. – Daniel Cortés Sep 3 '19 at 20:51
1

Since you are using the tag "Docker-Machine" I'm assuming that you are using Docker Toolbox to manage Docker. The problem is most likely an issue with Virtual Box configuration than your Docker configuration.

When you try pinging your container on port 9001, use the ip 0.0.0.0 instead of 127.0.0.1 or localhost. Another way to test would be to get the IP address of the docker-machine, docker-machine ip, and use this IP to ping your container (e.g. use 192.168.99.100:9001.

If you are trying to access the container from another computer you may have to look into a solution like port forwarding as described here.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.