1

I have an angular and nodejs app. The API's (nodejs) is running on port 8888 The Angular is running on port 8080

Now the app is running in a docker container. The container is running by:

docker run -d -p 49160:8080 --name app localhost:5000/test/app

The problem is. Now I'm able to visiting the API's on localhost:49160 but I don't know how to access my angular. Which is running on another port

Do I need 2 containers? In each tutorial I see it in the same container.

EDIT: this is my dockerfile:

FROM node

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

RUN npm install -g bower
RUN npm install -g gulp

# Install app dependencies
COPY . /usr/src/app/
RUN bower install
RUN npm install
RUN gulp build

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

My run command is:

docker run -d -p 49160:8080 -p 8888:8888 --name app localhost:5000/test/app

My angular is running on port 8080 and nodejs on 8888.

1 Answer 1

5

You can expose multiple ports of your Docker container by repeating the -p flag:

docker run -p <host_port1>:<container_port1> -p <host_port2>:<container_port2>

In your case you could do:

docker run -d -p 49160:8080 -p 8888:8888 --name app localhost:5000/test/app
Sign up to request clarification or add additional context in comments.

2 Comments

I've exposed the ports, didn't know that it was possible but still I can't see my angular.
Are you sure Angular is running on the expected port? You can use docker run -i -t -p 49160:8080 -p 8888:8888 localhost:5000/test/app /bin/bash to start it up and login to a terminal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.