How do I access nginx server logs from within Docker?

I have Nginx routing requests from the browser to either the Express API or my react server, however, in the console I continue to get xhr requests that are just pending and then timeout with 502 bad gateway error which are generally caused by Nginx being unable to pass a request to "upstream", in this case my Express API and normally I would be able to check the /var/log/nginx/ files, but I am not sure how to do that when all this is happening within a Docker container.

I have tried this approach of docker logs <container name/id> command, but I get Error: No such container: <container-id>.

I obtained the container id from the last line after running docker-compose up --build and it says Successfully built <container-id>

I copied that id and ran docker logs <container-id> on a second panel in my iTerm.

I then did a docker ps and got this output:

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
f37be54a9e60        complexly_api       "npm run dev"            43 minutes ago      Up 28 minutes                              complexly_api_1
9b87bc0aa343        complexly_nginx     "nginx -g 'daemon of…"   About an hour ago   Up 28 minutes       0.0.0.0:3050->80/tcp   complexly_nginx_1
1e30a05f8e28        complexly_worker    "npm run dev"            About an hour ago   Up 28 minutes                              complexly_worker_1
65611b5a6b05        complexly_client    "npm run start"          About an hour ago   Up 28 minutes                              complexly_client_1
9182b26fb402        redis:latest        "docker-entrypoint.s…"   About an hour ago   Up 28 minutes       6379/tcp               complexly_redis_1
8ca3596d8a50        postgres:latest     "docker-entrypoint.s…"   8 days ago          Up 28 minutes       5432/tcp               complexly_postgres_1

I believe I need to grab one of these container ids and do a docker logs with, but I am not sure.

The issue appears to be that I was running docker logs on the wrong container.

By running docker ps I saw the different containers I had running and copied the container id of the one marked complexly_nginx and was able to get the logs I was looking for.

Please show the exact commands you typed to lookup your container id and run the logs command.

Please copy and paste the exact commands you are running and their output, including the lookup of your container id. You are copying the wrong ID but I cannot see your screen to point you to the right one.

@BMitch, could I just do a docker ps and then grab the container id that belongs to nginx daemon? or whichever one is named nginx?