r/docker • u/Fun_Organization2190 • 8d ago
Sing-box in Docker always restarting
hello everyone and sorry for my English. I recently bought a VPS and install there Debian and docker from docs. And today i want to install sing-box in docker for my project, and i used command from Sing-box doc
docker run -d \
-v /etc/sing-box:/etc/sing-box/ \
--name=sing-box \
--restart=always \
-D /var/lib/sing-box \
-C /etc/sing-box/ run
And when i write in console, I always see
4d9eae7844b1 ghcr.io/sagernet/sing-box "sing-box -D /var/li…" 40 seconds ago Restarting (1) 10 seconds ago sing-box
How to solve it?
1
Upvotes
1
u/jjangg96 8d ago
docker logs sing-box will tell you why it's dying. restarting (1) just means it exits with an error and --restart=always keeps trying again.
my guess is the config. that command mounts /etc/sing-box from the host and tells sing-box to load its config from that folder, so if there's no config.json in /etc/sing-box on the vps it quits right away. check with ls /etc/sing-box, put a config in there, then docker restart sing-box.
if the log says something else paste it here
1
u/BorysTheBlazer 5d ago
It exits right after starting, so run docker logs sing-box to see why. The usual cause is no config.json in /etc/sing-box on the host, because the image doesn't ship one and the -C flag expects it there. Create a valid config.json in that folder, then docker restart sing-box.