Docker Community Forums

Share and learn in the Docker community.

Two application running same container connection refused

Hi,

I am indeed new to docker, but googled for the problem I have and could not found it,

the problem is that I have an image with 2 apps running, a server and one api,

I start the image mapping the port of the server, the one that needs to be accessed from

outside, I can then access it but the server cannot access the api on its exposed port.

FROM node:6.0

# create app dir
RUN mkdir -p /app
WORKDIR /app

# install the dependencies from the package.json file
COPY package.json /app
RUN npm install

# Bundle app source
COPY . /app

ENV NODE_ENV=development

# make port 8443 available outside of the image
EXPOSE 8443
EXPOSE 9443

#for development and testing we need 2 run
CMD [ "npm", "run", "dev" ]

I start the image:
docker run -p 8443:8443 -d whiteadi/app-web

both are started, sever is running on 8443, api on 9443
Server connecting to api get s connection refused:
https://localhost:9443/api/colors net::ERR_CONNECTION_REFUSED

I created a docker-compose file to run them separate and is working fine :wink: