community.docker icon indicating copy to clipboard operation
community.docker copied to clipboard

Is it possible to see errors from a container in community.docker.docker_compose_v2?

Open mihalt opened this issue 1 year ago • 5 comments

I would like not to ssh to my server with docker ps -a and after docker logs container_name each time when error occures in any container. And see them immidiately in ansible output. Is it possible?

mihalt avatar Oct 19 '24 17:10 mihalt

I'm not sure what exactly you need. A module which allows you to run docker logs <containername> for one / all containers for a service and/or project?

felixfontein avatar Oct 19 '24 17:10 felixfontein

@mihalt can you please provide more details, for example how you would do this without Ansible?

felixfontein avatar Oct 24 '24 18:10 felixfontein

I'm not sure what exactly you need. A module which allows you to run docker logs <containername> for one / all containers for a service and/or project?

For example I would like to have an option of you collection to choose one of this parameters of showing logs:

  1. Logs of first failled container with problems (by default)
  2. Show all failed containers log
  3. Show last failed container logs

Maybe something like this.

mihalt avatar Oct 25 '24 14:10 mihalt

So which command do you run without Ansible to achieve this? The docker_compose_v2 module allows you to run commands like docker compose up, docker compose down, etc.

felixfontein avatar Oct 27 '24 14:10 felixfontein

So which command do you run without Ansible to achieve this? The docker_compose_v2 module allows you to run commands like docker compose up, docker compose down, etc.

hmm, maybe docker compose logs, could be ok. But output is too big

mihalt avatar Oct 27 '24 17:10 mihalt

yes, to see container logs the command is: docker container logs **<container-id>** or **<container-name>** to go inside the container and see the log the command is: docker container exec -it **<container-name>** bash , to inspect files, logs internal to the container, configuration, etc. docker compose logs to see the stdout/stderr output from container

SiyaDadheech avatar Sep 14 '25 09:09 SiyaDadheech