Skip to content

Restrict to only a single IP #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ RUN apk update && apk add socat

EXPOSE 2375

CMD socat TCP-LISTEN:2375,reuseaddr,fork UNIX-CLIENT:/var/run/docker.sock
COPY run.sh /
ENTRYPOINT ["/run.sh"]
4 changes: 3 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Makes the Docker Remote API available via port 2375.

Start with:
`docker run -p 2375:2375 -v /var/run/docker.sock:/var/run/docker.sock jarkt/docker-remote-api`
`docker run -d -p 2375:2375 --name docker_remote_api -v /var/run/docker.sock:/var/run/docker.sock vhanda/docker-remote-api ALLOWED_IP`

Where `ALLOWED_IP` is the only IP which can connect to this machine.
12 changes: 12 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env sh

if [ -z "$1" ]; then
echo "First parameter must be the allowed IP"
exit 1
fi

set -eu
ALLOWED_IP=$1

echo "Starting Docker Remote API for IP $ALLOWED_IP"
socat TCP-LISTEN:2375,reuseaddr,fork,range=${ALLOWED_IP}/32 UNIX-CLIENT:/var/run/docker.sock