Run a terminal command before docker container starts


Recommended Posts

I'm trying to get a specific container to remove a file before the container is started. but i can't quite seem to get it to work

 

running "rm /mnt/user/storage/file.txt" from outside the container in the unraid temrinal works fine,

and running "rm /storage/file.txt" (where /mnt/user/storage:/storage) from inside the container console both work fine. but i cant seem to get the logic in the docker container settings.

 

i've tried both commands in the post arguments box but neither seems to run so i'm not sure what i'm supposed to do here.

Thanks!

Edited by MammothJerk
Link to comment

read other issues in this subforum and found my solution

&& docker exec containername sh -c 'rm /storage/file.txt'

 

So apparently this script only runs when the container is rebuilt, and not on start/restart

 

So i'm still looking for a solution

Edited by MammothJerk
Link to comment
  • MammothJerk changed the title to Run a terminal command before docker container starts
  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.