How to combine a Nginx and a NodeJS Docker container

I’ve a nodejs container which hosts my backend and I have a nginx container which is hosting my Angular.

They are both working fine. I’m able to visit my nodeJS container and I’m able to visit my Nginx-container.

  • Limiting a Docker Container to a single cpu core
  • Docker immediately stops the container
  • In Docker, apt-get install fails with “Failed to fetch … 404 Not Found” errors. Why? How can we get past it?
  • Docker container CPU allocation
  • Image deployment with config files
  • Docker create images “Ubuntu 14.04” with Docker file
  • The problem is there seems to be no connection between the containers.
    The nginx container is only hosting the /dist folder which contains the angular but nothing from the NodeJS.

    Do you have to edit the /etc/nginx/nginx.conf or the --link command for this?

    I read somewhere that your nodejs and nginx would bind automatically.

    My backend is running on 8888, frontend on 8080.

    nginx dockerfile (The npm install etc are already performed in jenkins)

    FROM nginx
    COPY dist /usr/share/nginx/html/dist
    FROM node

    Nodejs dockerfile

    RUN mkdir -p /usr/src/test
    WORKDIR /usr/src/test 
    COPY node_modules /usr/src/test/
    COPY server.js /usr/src/test/
    EXPOSE 8080
    CMD [ "node", "server.js" ]

    I start them by performing:

    docker run -d -p 80:80 --name "app" localhost:5000/test/nginx-image:1
    docker run -d -p 8888:8888 --name "app-" localhost:5000/test/nodejs-image:1

  • unable to find user root: no matching entries in passwd file
  • How do I run 2 environments of SkyDns/Skydock simultaneously?
  • Correct way to detach from a container without stopping it
  • Unable to correct problems, you have held broken packages
  • Can't seem to expose docker container port to host
  • how to mount an efs file system using docker in beanstalk
  • One Solution collect form web for “How to combine a Nginx and a NodeJS Docker container”

    You need to link the containers. Also when containera talks to containerb it will use http://container-name not http://localhost so your code should account for this. You will notice when you use link that inside the container docker will add an entry in the hosts file to this effect. Use environment variables so you can make the domain name to which you will make requests flexible. And pass this environment variables when you run the container

    Make sure u expose the right ports between containers

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.