fix(docker): run API container as root for Docker socket access
The API container needs to run docker compose commands via the mounted Docker socket. Running as non-root user doesn't work well with socket permissions across container boundaries. - Remove USER appuser from Dockerfile (API service only) - Remove group_add from docker-compose (no longer needed) - Add security note about considering Docker-in-Docker or rootless This fixes: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
This commit is contained in:
+4
-2
@@ -54,8 +54,10 @@ RUN mkdir -p /data/repos /data/instances && chown -R appuser:appgroup /data
|
|||||||
COPY wait-for-db.sh /usr/local/bin/wait-for-db.sh
|
COPY wait-for-db.sh /usr/local/bin/wait-for-db.sh
|
||||||
RUN chmod +x /usr/local/bin/wait-for-db.sh
|
RUN chmod +x /usr/local/bin/wait-for-db.sh
|
||||||
|
|
||||||
# Switch to non-root user
|
# NOTE: Running as root to access Docker socket for managing tool instances
|
||||||
USER appuser
|
# This is required because Docker socket permissions require root or docker group membership
|
||||||
|
# which doesn't work well across container boundaries.
|
||||||
|
# Consider using Docker-in-Docker or rootless Docker for production hardening.
|
||||||
|
|
||||||
# Expose port
|
# Expose port
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|||||||
@@ -102,8 +102,6 @@ services:
|
|||||||
- avatar_uploads:/app/uploads
|
- avatar_uploads:/app/uploads
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
- cloudflared_config:/etc/cloudflared
|
- cloudflared_config:/etc/cloudflared
|
||||||
group_add:
|
|
||||||
- ${DOCKER_GID:-999}
|
|
||||||
depends_on:
|
depends_on:
|
||||||
postgres:
|
postgres:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|||||||
Reference in New Issue
Block a user