Home > Software design >  Docker-compose not show logs
Docker-compose not show logs

Time:12-30

I'm runing my api of express and mongo with docker-compose using the command docker-compose up, all fine but when i try show the logs have the next output error: enter image description here

CodePudding user response:

This is a common confusion point with docker-compose orchestration. Docker compose deals with services, which then can start one or more containers for a service.
You can clarify this for yourself by looking at the manual page for whatever command you plan to use, as it will tell you whether it requires a service name or a container name.

For docker-compose logs the manual shows:

Usage: logs [options] [SERVICE...]

Since we don't have your docker-compose.yaml to refer to, we can only infer that you may have named the service backend_api. I'm just repeating the answer provided by Dennis van de Hoef, which is a reasonable guess based on how docker will name containers for you.

docker-compose logs -f backend_api

The [docker logs][1] command can be used to look at the logs of a container.

docker logs -f backend_api_1

CodePudding user response:

With docker-compose logs you need to use the name of the service in the docker-compose.yaml not the name of the container.

You ran docker-compose logs -f backend_api_1, which is the name of the container. If your docker-compose file does not contain any special renaming, the following should work: docker-compose logs -f backend_api (assuming the service is called backend_api)

  • Related