Home > Enterprise >  Docker-compose logs for yml with non-default name
Docker-compose logs for yml with non-default name

Time:03-30

I have 2 docker-compose files.
One of them has a non-default docker-compose file name docker-compose-services.yml.
The second one is docker-compose.yml.

I need to follow logs from time to time for docker-compose-services.yml. Is there an option to follow logs for docker-compose-services.yml or for a project, if I wrap the containers up into one project?

I tried:
docker-compose logs -f - for containers defined in docker-compose.yml.
docker-compose logs --file - does not exist.
docker ps -q | xargs -L 1 docker logs - logs for all running containers. That's not what I need.

CodePudding user response:

To view the logs for non-default docker-compose file (docker-compose-services.yml), you need to specify the file name before the logs command.

Let's say we have a redis container in docker-compose-services.yml

version: "3.3"
services:
  redis:
    image: "redis:alpine"

We can view the logs using this command

docker-compose -f docker-compose-service.yaml logs -f
  • Related