Score:0

docker run script at start, commit changes and remove script mounted

ve flag
sak

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!

Score:0
ru flag

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

sak avatar
ve flag
sak
I cannot use --rm as I need to use the container and commit the changes made in container back to image
Klamber avatar
ru flag
Maybe an intermediate container would help? https://docs.docker.com/develop/develop-images/multistage-build/
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.