Move docker image and start as service

I can start Librechat docker image under ~/Librechat at my home directory on ubuntu via command “docker compose up -d”. I want to

  1. move it to system folder like /opt then
  2. start it with absolute path as system service with systemctl

However I get all kinds of errors:
WARN[0000] The “UID” variable is not set. Defaulting to a blank string.
WARN[0000] The “GID” variable is not set. Defaulting to a blank string.
LibreChat/docker-compose.yml: version is obsolete
Binding point is not found even the file exists.

May I ask what’s the established convention to start docker as service and what’s the proper way to move docker image around without error? Thanks.

Docker itself is a service, Docker services will automatically restart when setting the restart mode (always, unless_stopped).

Why would you want to move it to opt? If you need to move data directories, just use a bind mount folder from host for that folder.

I agree with @bluepuma77 regarding the restart policy. Do you have any reason not to use it or you just haven’t heeard about it?

That is application specific. Normally those variables are not needed, but available in a shell. If you run a docker command in systemd that can have different variables. I’m not sure if UID and GID are available there by default, but you can always create a wrapper shell script and execute that instead of docker commands directly.

That is not a systemd issue. the version keyword should be deleted from your compose file as it is ignored anyway in compose v2.

Just guessing that you are using that tilde character and your systemd service is not running as the user you think.

I just tried to answer the original question even though I still think the restart policy can solve your problem without systemd.

I use the same method. I create a /opt/compose-projects/ and each project there. Not the data, but is just a way to organize application files even if docker compose ls could reveal where the compose projects are.

Thank you both for the restart mode.
For /opt folder, I just want to organize all docker images in a central place, not just bind mount some folders. In docker, it should allow this after the first run.