Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Idea: docker compose watch --prune #11073

Closed
arjasco opened this issue Oct 8, 2023 · 3 comments
Closed

Idea: docker compose watch --prune #11073

arjasco opened this issue Oct 8, 2023 · 3 comments

Comments

@arjasco
Copy link

arjasco commented Oct 8, 2023

Description

Having just started using watch to rebuild a Go application on code changes, I'm quite happy! It's a solid feature that means I no longer need to rely on other tools to watch for file changes.

I've done some searching around but haven't found any discussion on tidying up dangling images after the numerous if not hundreds of rebuilds that could occur throughout the day.

Adding a --prune option to the command that does this automatically would be a nice next addition.

At present you only have the following options (as far as I'm aware):

  • Run docker system prune manually once in a while.
  • Set up a cronjob to run the above command to remove the manual element.
  • Or a little more programatic would be to pipe the output of docker system events to another process, pulling out the label for com.docker.compose.service and providing that as a filter to the prune command.

All are undesirable, you might not want this running all the time on a schedule and anything manual is going against the point of having a watcher in the first instance to build / sync.

@nivpenso
Copy link

I have the exact same issue.

I thought of solving it by adding an additional field keep_dangled_image to the configuration of the rebuild action section.

by default keep_dangled_image will be true, and everything will act as today. but if it is false, the compose will delete the image that became dangled after rebuilding the image

services:
  nginx:
    build:
      context: .
    develop:
      watch:
        - action: rebuild
          path: ./deps/nginx/nginx.conf
          keep_dangled_image: false

@g0t4
Copy link
Contributor

g0t4 commented Dec 5, 2023

This could work for any compose project with a build.

services:
  nginx:
    build:
      context: .
      prune: true

@idsulik
Copy link
Collaborator

idsulik commented Aug 31, 2024

hi everyone! It was implemented and released.
I think we can close the issue, @ndeloof fyi

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

5 participants