Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
PRADA SLUT
Mar 14, 2006

Inexperienced,
heartless,
but even so
I have a docker container on a Synology NAS that updates some Sonarr config things. However, I need to manually pass a (sudo) command to docker through the CLI when I want to update (sudo docker exec..)

What's the best way to have this command run automatically every day at a specific time?

e: also because I have to SSH in to run commands and I don't want to leave that open so I have to turn it on and back off each time

PRADA SLUT fucked around with this message at 04:22 on Apr 21, 2024

Adbot
ADBOT LOVES YOU

IUG
Jul 14, 2007


Can’t you just add your user to the “docker” group to avoid sudo?

Tatsuta Age
Apr 21, 2005

so good at being in trouble


sudo crontab -e

that's it, that's all ya gotta do

PRADA SLUT
Mar 14, 2006

Inexperienced,
heartless,
but even so

Tatsuta Age posted:

sudo crontab -e

that's it, that's all ya gotta do

Command not found. Is there a way to set up a script or something through the UI, such that I can manage these items without needing to constantly open and close SSH? Like a way to write some commands I want in a .sh file and shove that on a drive somewhere to have the NAS run at some interval?

IUG posted:

Can’t you just add your user to the “docker” group to avoid sudo?

How do I know what user docker execs as? I have some containers I pass PUID and PGID but I don't know how those relate to a specific user and how to find/set them otherwise

This is what I get now when I run as non-sudo but I don't know how to tell the perms I need:

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/recyclarr/json": dial unix /var/run/docker.sock: connect: permission denied

PRADA SLUT fucked around with this message at 06:34 on Apr 21, 2024

Matt Zerella
Oct 7, 2002

Norris'es are back baby. It's good again. Awoouu (fox Howl)
If you add your user to the docker group it doesn't affect your UID/GID. It will let you run docker without the need for sudo. That's it.

Then you can crontab -e as your login user and add your docker commend or wrap it in a script (remember that crontab runs as /bin/sh and doesn't have your regular bash profile available in it, so a wrapper script with it sourced is your best bet).

IUG
Jul 14, 2007


Yeah your error isn’t in Docker, it’s permission denied trying to run Docker commands. The container isn’t having the issue.

PRADA SLUT
Mar 14, 2006

Inexperienced,
heartless,
but even so
I guess what I’m asking is that I don’t know which user docker executes as, since there’s no user groups I see impacting docker in my Synology user/group settings.

Matt Zerella
Oct 7, 2002

Norris'es are back baby. It's good again. Awoouu (fox Howl)
Why the hell are you dicking around in CLI on a Synology anyway?

EVIL Gibson
Mar 23, 2001

Internet of Things is just someone else's computer that people can't help attaching cameras and door locks to!
:vapes:
Switchblade Switcharoo

Matt Zerella posted:

Why the hell are you dicking around in CLI on a Synology anyway?

Something that needs done.

PRADA SLUT posted:

I have a docker container on a Synology NAS that updates some Sonarr config things. However, I need to manually pass a (sudo) command to docker through the CLI when I want to update (sudo docker exec..)

Matt Zerella
Oct 7, 2002

Norris'es are back baby. It's good again. Awoouu (fox Howl)
That should be done inside of the docker container, not from the host CLI, wtf.

EVIL Gibson
Mar 23, 2001

Internet of Things is just someone else's computer that people can't help attaching cameras and door locks to!
:vapes:
Switchblade Switcharoo

Matt Zerella posted:

That should be done inside of the docker container, not from the host CLI, wtf.

Wtf, the dude wanted automatic updates which it seems is not possible in the OPs current situation, wtf?

Maybe help out with an answer?

Edit: reminder. The guy could not access crontab -e.

EVIL Gibson fucked around with this message at 20:36 on Apr 21, 2024

Matt Zerella
Oct 7, 2002

Norris'es are back baby. It's good again. Awoouu (fox Howl)

EVIL Gibson posted:

Wtf, the dude wanted automatic updates which it seems is not possible in the OPs current situation, wtf?

Maybe help out with an answer?

If this is recyclarr it's got built in cron inside of the container. Trying to automate this by firing a command into the docker and potentially breaking the implementation on a device meant to be used with a GUI is an exercise in futility. I'm trying to help here by saying this is not the right way to go about this!

other people
Jun 27, 2004
Associate Christ
Pull the latest image and recreate the container. Not having to janitor the packages inside the container is kinda what makes containers so useful and easy.

IOwnCalculus
Apr 2, 2003





PRADA SLUT posted:

I guess what I’m asking is that I don’t know which user docker executes as, since there’s no user groups I see impacting docker in my Synology user/group settings.

You don't need to know because your ability to run a docker command without sudo in front of it is not determined by what user owns the docker process. It is determined by whether the user you are logged in as, has permission to run docker commands without sudo. IUG already gave you the answer here.

On most distros this would be a usermod command, but Synology is special according to this post I found.

While I'm a big proponent of docker without sudo, I do agree that this probably isn't the best way to handle whatever specific task you're actually trying to do.

PRADA SLUT
Mar 14, 2006

Inexperienced,
heartless,
but even so

Matt Zerella posted:

If this is recyclarr it's got built in cron inside of the container. Trying to automate this by firing a command into the docker and potentially breaking the implementation on a device meant to be used with a GUI is an exercise in futility. I'm trying to help here by saying this is not the right way to go about this!

I see the docs how it asks for docker compose up -d to start in cron mode, but how do I implement this? Docker compose isn't a command the CLI recognizes. I just want this to update daily without any intervention. Is this a variable I call out in my compose yml? I can't pass up -d through an exec either.

When I view the environment vars in DSM it lists CRON_SCHEDULE @daily but I don't know if that means it's running daily or if its just holding that timeframe waiting for some type of launch parameter.

other people posted:

Pull the latest image and recreate the container. Not having to janitor the packages inside the container is kinda what makes containers so useful and easy.

I already have Watchtower to update containers but it only runs when there's a new release of something.

PRADA SLUT fucked around with this message at 06:18 on Apr 22, 2024

other people
Jun 27, 2004
Associate Christ

PRADA SLUT posted:

I already have Watchtower to update containers but it only runs when there's a new release of something.

If the contents of the image need updating then there should be a new release of the container image. Though you originally say you are trying to update "some Sonarr config things" which almost sounds like the container isn't an app or has some baked in configs that you need to modify???

Anyway, I know you are likely not the image author so you may not be able to control this stuff directly but in general if one is needing to modify/update bits of the shipped image then you are doing it wrong.

Maybe the bits you need to update can instead be on a volume mounted in the container so a host process can easily modify them without touching the container? Or if they have to be part of the baked image then it isn't too difficult to have your own Dockerfile that extends the image you are using.

:shrug: sorry to keep harping on this but whatever solution you find for your current task is going to be clunky because it goes against what the tools are designed to help do.

Matt Zerella
Oct 7, 2002

Norris'es are back baby. It's good again. Awoouu (fox Howl)

PRADA SLUT posted:

I see the docs how it asks for docker compose up -d to start in cron mode, but how do I implement this? Docker compose isn't a command the CLI recognizes. I just want this to update daily without any intervention. Is this a variable I call out in my compose yml? I can't pass up -d through an exec either.

When I view the environment vars in DSM it lists CRON_SCHEDULE @daily but I don't know if that means it's running daily or if its just holding that timeframe waiting for some type of launch parameter.

I already have Watchtower to update containers but it only runs when there's a new release of something.

https://recyclarr.dev/wiki/installation/docker/#cron-mode

Checking the documentation, by default the cron mode is set to daily. You only need to set that variable if you want to modify that schedule (you don't, mine runs default). So basically you don't need to do anything lol.

You can check your logs for the docker container and you should see it running once a day.

Adbot
ADBOT LOVES YOU

Matt Zerella
Oct 7, 2002

Norris'es are back baby. It's good again. Awoouu (fox Howl)
hey PS, did recyclarr update today?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply