docker-compose for nginx and nodejs server

Solution 1:

You use the container's name as you defined it in docker-compose.yml. Docker provides the IP addresses for the named containers via DNS within each container, and updates them if the containers are updated.

In this case, you called it server, so that is what you would use.

    proxy_pass http://server:8000;

Documentation: Networking in Compose

Solution 2:

In this case, you need to use upstream like:

upstream backend {
    server express-server:81; #you container/service name
}

and then use:

proxy_pass http://backend