How can I run a command when I do a docker compose up -d??? Right now, I’m good as long as no ‘command:’ is in the docker-compose.yml?
I am running syncthing inside a docker-compose.yml successfully. Because each time I have to issue a command in the running docker container, I wanted to add that to the docker-compose.yml file. I have tried every format I can find on the web (over 7 of them lol).
//examples I’ve used of command//
command: >
command:
command:
|
//example//
I use this to start successfully as long as I don’t have any command in the file:
docker compose up -d
Now when I add a “command:” to this same docker-compose.yml, I watch the logs and get a “signal 15”. I could just be using command: echo.
Here is the docker-compose.yml
services:
syncthing:
image: lscr.io/linuxserver/syncthing:latest
container_name: syncthing
hostname: syncthing #optional
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
volumes:
- /srv/DOCKER/syncthing/config:/config
- /srv/DOCKER/syncthing/config:/data
#- /path/to/data2:/data2
ports:
- 8384:8384
- 22000:22000/tcp
- 22000:22000/udp
- 21027:21027/udp
restart: unless-stopped
command: echo “fs.inotify.max_user_watches=655341” | sudo tee -a /etc/sysctl.conf
Here is the output log when I add the “command” line.
───────────────────────────────────────
██╗ ███████╗██╗ ██████╗
██║ ██╔════╝██║██╔═══██╗
██║ ███████╗██║██║ ██║
██║ ╚════██║██║██║ ██║
███████╗███████║██║╚██████╔╝
╚══════╝╚══════╝╚═╝ ╚═════╝
Brought to you by linuxserver.io
───────────────────────────────────────
To support LSIO projects visit:
───────────────────────────────────────
GID/UID
───────────────────────────────────────
User UID: 1000
User GID: 1000
───────────────────────────────────────
[custom-init] No custom files found, skipping…
[start] 2024/06/05 21:53:59 INFO: syncthing v1.27.8 “Gold Grasshopper” (go1.21.10 linux-amd64) root@buildkitsandbox 2024-06-04 12:18:01 UTC [noupgrade]
[MCYDS] 2024/06/05 21:53:59 INFO: My ID: MCYDS3Z-PHIKQQA-ZDVH6PD-QCQ4FUB-TTDCYGI-FPI23EV-LZ6ANWV-DTDBTAO
[MCYDS] 2024/06/05 21:54:00 INFO: Single thread SHA256 performance is 1869 MB/s using crypto/sha256 (1851 MB/s using minio/sha256-simd).
[MCYDS] 2024/06/05 21:54:01 INFO: Hashing performance is 971.12 MB/s
[MCYDS] 2024/06/05 21:54:01 INFO: Overall send rate is unlimited, receive rate is unlimited
[MCYDS] 2024/06/05 21:54:01 INFO: Using discovery mechanism: global discovery server blahs://discovery.syncthing.net/v2/?noannounce&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[MCYDS] 2024/06/05 21:54:01 INFO: Using discovery mechanism: global discovery server blahs://discovery-v4.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[MCYDS] 2024/06/05 21:54:01 INFO: Using discovery mechanism: global discovery server blahs://discovery-v6.syncthing.net/v2/?nolookup&id=LYXKCHX-VI3NYZR-ALCJBHF-WMZYSPK-QG6QJA3-MPFYMSO-U56GTUK-NA2MIAW
[MCYDS] 2024/06/05 21:54:01 INFO: Using discovery mechanism: IPv4 local broadcast discovery on port 21027
[MCYDS] 2024/06/05 21:54:01 INFO: Ready to synchronize “Default Folder” (default) (sendreceive)
[MCYDS] 2024/06/05 21:54:01 INFO: Using discovery mechanism: IPv6 local multicast discovery on address [ff12::8384]:21027
[MCYDS] 2024/06/05 21:54:01 INFO: Relay listener (dynamic+blahs://relays.syncthing.net/endpoint) starting
[MCYDS] 2024/06/05 21:54:01 INFO: TCP listener ([::]:22000) starting
[MCYDS] 2024/06/05 21:54:01 INFO: Completed initial scan of sendreceive folder “Default Folder” (default)
2024/06/05 21:54:01 failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 7168 kiB, got: 416 kiB). See blah://github.com/quic-go/quic-go/wiki/UDP-Buffer-Sizes for details.
[MCYDS] 2024/06/05 21:54:01 INFO: GUI and API listening on [::]:8384
[MCYDS] 2024/06/05 21:54:01 INFO: Access the GUI via the following URL: blah://127.0.0.1:8384/
[MCYDS] 2024/06/05 21:54:01 INFO: My name is “syncthing”
[MCYDS] 2024/06/05 21:54:01 INFO: QUIC listener ([::]:22000) starting
Connection to localhost (::1) 8384 port [tcp/*] succeeded!
[ls.io-init] done.
[monitor] 2024/06/05 21:54:01 INFO: Signal 15 received; exiting
[MCYDS] 2024/06/05 21:54:01 INFO: Detected 1 NAT service
[MCYDS] 2024/06/05 21:54:01 INFO: QUIC listener ([::]:22000) shutting down
[MCYDS] 2024/06/05 21:54:01 INFO: Relay listener (dynamic+blahs://relays.syncthing.net/endpoint) shutting down
[MCYDS] 2024/06/05 21:54:02 INFO: TCP listener ([::]:22000) shutting down
[MCYDS] 2024/06/05 21:54:02 INFO: Exiting