Fix docker issues

This commit is contained in:
quietsy 2025-11-25 18:37:34 +02:00
parent 8f0cbfcd08
commit 2c4538354a
3 changed files with 20 additions and 2 deletions

View File

@ -83,4 +83,4 @@ Here's a sample compose yaml snippet for `linuxserver/docker-socket-proxy`:
tmpfs:
- /run
```
Then the env var in SWAG can be set as `DOCKER_HOST=tcp://socket-proxy:2375`. This will allow docker in SWAG to be able to start/stop existing containers, but it won't be allowed to spin up new containers.
Then the env var in SWAG can be set as `DOCKER_HOST=socket-proxy`. This will allow SWAG to be able to start/stop existing containers, but it won't be allowed to spin up new containers.

View File

@ -20,9 +20,16 @@ class ContainerThread(threading.Thread):
self.daemon = True
self.ondemand_containers = {}
try:
self.docker_client = docker.from_env()
docker_host = os.environ.get("DOCKER_HOST", None)
if docker_host:
if not docker_host.startswith("tcp://"):
docker_host = f"tcp://{docker_host}:2375"
self.docker_client = docker.DockerClient(base_url=docker_host)
else:
self.docker_client = docker.from_env()
except Exception as e:
logging.exception(e)
os._exit(1)
def process_containers(self):
containers = self.docker_client.containers.list(all=True, filters={ "label": ["swag_ondemand=enable"] })

View File

@ -0,0 +1,11 @@
/config/log/ondemand/*.log {
weekly
rotate 14
compress
delaycompress
nodateext
notifempty
missingok
sharedscripts
su abc abc
}