stchas Posted January 9, 2016 Share Posted January 9, 2016 I'd like to be able to automatically run a script after a docker container starts. How might I do that? Couple of examples of what I'd like to do: [*]change the permissions on appdata/crashplan/conf/service.model to 0666 (changed to 0600 in CP rev 4.5, creates SyncBack error) [*]create a revised appdata/crashplan/id/.ui_info with the unRAID server IP address substituted for 0.0.0.0 (broken in CP circa rev 4.1?) I don't need help creating the script(s); what I need help on is figuring out how to have the docker manager run the script(s) automatically when the container is started. Thanks in advance for your help! Quote Link to comment
BRiT Posted January 9, 2016 Share Posted January 9, 2016 Change the docker container itself to have that done on startup. Depending on which docker container and which base image they use will determine how to hook into that startup. You could do it on the unraid side, but why not fix what was broken where it was broken to begin with? If you're using a LinuxServer container I'm sure the fine folks there would help you out. I could also see them changing all there containers to support user adjustable startup scripts as a new feature. Quote Link to comment
lionelhutz Posted January 9, 2016 Share Posted January 9, 2016 You basically put the script in your GitHub repository and then put commands like this at the end of the Dockerfile to install and run it. ADD install.sh /tmp/ RUN chmod +x /tmp/install.sh && /tmp/install.sh && rm /tmp/install.sh The above copies the script install.sh into the docker, runs it and then deletes it. But then, I'm guessing you really want to do it without creating your own repository, right? Quote Link to comment
stchas Posted January 9, 2016 Author Share Posted January 9, 2016 ... why not fix what was broken where it was broken to begin with? The two items I'm working on are work-arounds for changes Code42 implemented in recent revisions of CrashPlan. They have not been particularly responsive to requests for relief. You know the drill: "... running the CrashPlan service on a headless computer is an unsupported feature..." and "... security decision made by our engineers that we have no intention of reversing." If you're using a LinuxServer container ... No, this is a gfjardim container But then, I'm guessing you really want to do it without creating your own repository, right? Right; wasn't quite ready to take that step. I was really hoping there was a generic hook in the docker manager that would facilitate user scripts that I didn't know about. I can't believe I'm the only one that might see a use for this feature. Thanks for the ideas, guys! Quote Link to comment
Flick Posted May 14, 2017 Share Posted May 14, 2017 Did you ever find a way to do this? Thanks! Quote Link to comment
Squid Posted May 14, 2017 Share Posted May 14, 2017 (edited) 31 minutes ago, Flick said: Did you ever find a way to do this? Thanks! Easiest solution would be to set the docker app to NOT autostart, then create a user script vis a vis user scripts plugin set to run at array start containing something like this: sleep xxx (xxx is however long it takes for the other containers, VMs, etc to get up and running) docker start nameOfContainer whateverOtherCommandsYouWant Edited May 14, 2017 by Squid 2 Quote Link to comment
Osiris Posted March 13, 2018 Share Posted March 13, 2018 On 14-5-2017 at 8:58 PM, Squid said: Easiest solution would be to set the docker app to NOT autostart, then create a user script vis a vis user scripts plugin set to run at array start containing something like this: sleep xxx (xxx is however long it takes for the other containers, VMs, etc to get up and running) docker start nameOfContainer whateverOtherCommandsYouWant Although this is a cool way to have a post-startup script for the initial container launch, right after the array startup, this would not make the container restartable with the script. For example, I want to run docker network connect bridge poste right after the poste container - which is on a macvlan - starts, to add a second network to the container. However, I might want to restart / stop-start the container at runtime. I'd love to have a post-start and post-stop command (to be run on the host) option in the docker GUI. I can think of a few more examples that cannot be included in the dockerfile. 2 Quote Link to comment
bj___ Posted August 15, 2023 Share Posted August 15, 2023 I just added in the "Post Arguments" box the following to install ffmpeg into the nextcloud container after it has been started: && docker exec -u root nextcloud bash -c "apt update && apt install -y ffmpeg" The "&&" causes the docker run command to finish and upon success executes what comes after it as a new command. You can put in whatever you like. Works for me, hopefully it works for others as well. But I agree that maybe another script box would be nicer and cleaner. Quote Link to comment
dRuEFFECT Posted February 6 Share Posted February 6 On 8/15/2023 at 5:08 AM, bj___ said: I just added in the "Post Arguments" box this was very helpful and works for my use case, thanks! Quote Link to comment
Recommended Posts
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.