Skip to content

Instantly share code, notes, and snippets.

@hazcod
Last active April 6, 2022 03:06
Show Gist options
  • Save hazcod/ccbadddd1843569d1a94f660a9f6e542 to your computer and use it in GitHub Desktop.
Save hazcod/ccbadddd1843569d1a94f660a9f6e542 to your computer and use it in GitHub Desktop.
Expose docker.sock on a TCP socket.
FROM alpine
# the group id of the docker group on the host
ENV HOST_DOCKER_GID 101
# SECURITY CONSIDERATIONS:
# Only expose this via a dedicated internal, encrypted net to your webserver/..
# Mount /var/run/docker.sock READONLY, make this container readonly too
RUN addgroup -g $HOST_DOCKER_GID docker \
&& adduser -H -D -G docker -s /bin/true socat
RUN apk add -U socat \
&& rm -rf /var/cache/apk*
USER socat
EXPOSE 9090
CMD /usr/bin/socat -d -d TCP-L:9090,fork UNIX:/var/run/docker.sock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment