Page 1 of 1

Any way to execute scripts from running container?

Posted: 25 Sep 2024, 21:33
by markmarz
I've installed the FileBot container using Portainer on Debian and am able to execute the GUI just fine.

What I'd like to do is to execute Groovy scripts .. built-in as well as custom .. from that running container. My first thought was to use

Code: Select all

docker exec -it FileBot bash
.. but how then pass a script name?

Re: Any way to execute scripts from running container?

Posted: 26 Sep 2024, 04:40
by rednoah
:arrow: The docker manual has got you covered:

Shell: Select all

# Run `filebot -script fn:sysinfo`
docker run --rm -it -v "data:/data" -v "$PWD:/volume1" rednoah/filebot -script fn:sysinfo
** you notably want to start a new container for each filebot call since filebot is a command-line tool (starts and stops) and not a web service (starts and runs indefinitely)



:idea: This bit calls filebot inside a docker container:

Shell: Select all

docker run --rm -it -v "data:/data" -v "$PWD:/volume1" rednoah/filebot
:idea: This bit is the command-line arguments passed onto the filebot call:

Shell: Select all

-script fn:sysinfo



:arrow: See How do I start an interactive shell session inside the container? if you want to start an interactive shell inside the rednoah/filebot container.

Re: Any way to execute scripts from running container?

Posted: 26 Sep 2024, 12:23
by markmarz
Sorry I missed those docs. But it turns out I don't completely understand them anyway.

I ran your example, substituting my data path, but I'm sorry to say I don't understand what "$PWD:/volume1" refers to. So I left it out, and it "worked", but I don't know what I've done. I expected a volume to point to a configuration directory, perhaps that's what that is about, and by not supplying it a default one was built and referenced?

On my system, the existing FileBot container has these volumes:
Image

Also, isn't this instantiating an entirely new container rather than using the one I've installed with Portainer? It's okay if it is, I just need to better understand if you don't mind a little more hand holding.

Code: Select all

root@omv:~# docker run --rm -it -v "/srv/mergerfs/mergerfs/Movies_Not_Shared:/storage"   rednoah/filebot -script fn:sysinfo
Unable to find image 'rednoah/filebot:latest' locally
latest: Pulling from rednoah/filebot
857cc8cb19c0: Pull complete
2705fd8a634e: Pull complete
f55d51f0a4b6: Pull complete
ed3f765c6a57: Pull complete
Digest: sha256:5ab7b7c547b21ef2f2c9c3660ea49d27018d1c422122866946a1389af616364d
Status: Downloaded newer image for rednoah/filebot:latest
--------------------------------------------------------------------------------

Hello! Do you need help Getting Started?

# FAQ
https://www.filebot.net/linux/docker.html

# Read License Key from Console
docker run --rm -it -v data:/data -e PUID=1000 -e PGID=1000 rednoah/filebot --license

--------------------------------------------------------------------------------

# env
USER=filebot(1000)
HOME=/data/filebot


Initialize Cache folder: /data/filebot/cache
Initialize Logs folder: /data/filebot/logs
Initialize new disk cache: /data/filebot/cache/0
Sep 26, 2024 11:50:46 AM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
FileBot 5.1.5 (r10380)
JNA Native: 6.1.1
MediaInfo: 21.09
Tools: fpcalc/1.5.1 7z/16.02 unrar/6.11 mkvpropedit/65.0.0 AtomicParsley/8
Extended Attributes: OK
Unicode Filesystem: OK
Script Bundle: 2024-09-10 (r980)
Groovy: 4.0.21
JRE: OpenJDK Runtime Environment 21.0.4
JVM: OpenJDK 64-Bit Server VM
CPU/MEM: 8 Core / 2.0 GB Max Memory / 44 MB Used Memory
OS: Linux (amd64)
HW: Linux 75c3eba3bd8f 6.1.0-25-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.106-3 (2024-08-26) x86_64 x86_64 x86_64 GNU/Linux
CPU/MEM: : 12th Gen Intel(R) Core(TM) i3-12100 / MemTotal: 8 GB / MemFree: 128 MB / MemAvailable: 6 GB / SwapCached: 25 MB / SwapTotal: 1.0 GB / SwapFree: 22 MB
STORAGE: overlay [/] @ 199 GB | fuse.mergerfs [/storage] @ 9 TB
UID/GID: uid=1000(filebot) gid=1000(filebot) groups=1000(filebot)
DATA: /data/filebot
Package: DOCKER
License: UNREGISTERED
Done ヾ(@⌒ー⌒@)ノ
root@omv:
Finally, I think I'm pulling a different image than I've used in Portainer. I thought the one I was using was official, but perhaps not?
Portainer: jlesage/filebot:latest
Cmd line: rednoah/filebot
Image

Sorry for so many questions! Thanks in advance.

Re: Any way to execute scripts from running container?

Posted: 26 Sep 2024, 13:47
by rednoah
:idea: $PWD is the current working directory. If you do -v "$PWD:/volume1" then the current working directory will be exposed inside the container under /volume1 so that you can rename files. You can do -v "/path/to/my/media:/volume1" if you want to volume mount a specific file path from the host into the container.


:idea: -v "data:/data" is required for persistent storage, so that FileBot does not start with a blank slate every single time. You need to add it to the docker command, otherwise FileBot will not work correctly and think it's running for the first time every time. This is the configuration directory. We use named volume "data" and not a host directory for simplicity.


:arrow: You can do -v "/srv:/srv" to expose all of host /srv as /srv inside the container for simplicity, that way all the file paths make sense in both host context and container context:

Shell: Select all

docker run --rm -it -v "data:/data" -v "/srv:/srv" rednoah/filebot -find /srv

Re: Any way to execute scripts from running container?

Posted: 26 Sep 2024, 18:13
by markmarz
Okay, so rednoah/filebot is the official Docker image, not jlesage/filebot? I think that accounts for some of my confusion. The docs I've been looking at aren't for your image.

Thank you also for explaining the purpose of $PWD:/volume1 and for your suggestion to expose all of /srv.

I believe I understand enough to trundle along with what you've given me. I think when I run the correct Docker from the command line, as you've shown, I'll be executing a container separate from the container running in Portainer, even when I switch to your image in Portainer. That was my original question, it doesn't really matter much. And I think the link you gave me will also show me how to run off the same container:

See How do I start an interactive shell session inside the container? if you want to start an interactive shell inside the rednoah/filebot container.

But really I'm not sure it's worth the candle. All I will have accomplished is saving the disk space for a downloaded image. Right?

Re: Any way to execute scripts from running container?

Posted: 27 Sep 2024, 04:49
by rednoah
:arrow: The list of official images and usage instructions can be found by following the following link:
https://www.filebot.net/linux/docker.html


:idea: Each docker run call will indeed instantiate a new container instance. The rednoah/filebot container in particular only runs the filebot command-line tool and will never keep running in the background as a service, but you can of course use --entrypoint to run bash instead of filebot and it will run and wait for command input.


:idea: We generally do not worry about disk space when we use docker. We use docker for convenience, and disk space micro-optimizations are probably not worth the effort.