0

I have a script that I want to run on existing images. For this I mount the script while running the container, commit changes and replace the image. The problem with binding the script at start is that the volume stays in new image too.In running an inspect on the image I can see it becomes a permannet argument and the run fails as the host system does not have the one time script.

Is there any way that the script runs, makes OS level changes and is removed completely. The script is fairly involved and calls a bunch of other scripts too.

command to run conatainer with script

 docker run --name temp_container --ipc host -v /path_to_scripts_dir:/new_dir iamge bash -v /new_dir/call_scripts.sh'

New to docker, any pointers would help!

sak
  • 1
  • 1

1 Answers1

0

You could try with the --rm flag.

By default a container’s file system persists even after the container exits. This makes debugging a lot easier (since you can inspect the final state) and you retain all your data by default. But if you are running short-term foreground processes, these container file systems can really pile up. If instead you’d like Docker to automatically clean up the container and remove the file system when the container exits, you can add the --rm flag

Docker run reference

Paperclip
  • 166
  • 8
  • I cannot use --rm as I need to use the container and commit the changes made in container back to image – sak May 02 '22 at 16:58
  • Maybe an intermediate container would help? https://docs.docker.com/develop/develop-images/multistage-build/ – Paperclip May 02 '22 at 18:25