skip to Main Content

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

2

Answers


  1. 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)

    Login or Signup to reply.
  2. 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 command can be used to look at the logs of a container.

    docker logs -f backend_api_1
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search