mirror of
https://github.com/Tecnativa/docker-socket-proxy
synced 2025-01-03 04:10:55 +00:00
Provide the ability to bind to a Unix socket
This commit is contained in:
parent
0e8d6601b6
commit
ef17b3a56e
26
README.md
26
README.md
@ -153,6 +153,32 @@ For example, [balenaOS](https://www.balena.io/os/) exposes its socket at
|
|||||||
`/var/run/balena-engine.sock`. To accommodate this, merely set the `SOCKET_PATH`
|
`/var/run/balena-engine.sock`. To accommodate this, merely set the `SOCKET_PATH`
|
||||||
environment variable to `/var/run/balena-engine.sock`.
|
environment variable to `/var/run/balena-engine.sock`.
|
||||||
|
|
||||||
|
## Exposing as a Unix socket
|
||||||
|
|
||||||
|
If you'd like to expose the proxy as a Unix socket, you can do so by setting the
|
||||||
|
`BIND_CONFIG` environment variable.
|
||||||
|
|
||||||
|
As an example, the following command will start the proxy and bind to the socket at
|
||||||
|
`/sockets/docker.sock`. Since this is a volume, this could then be shared with another
|
||||||
|
container.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ docker container run \
|
||||||
|
-d --privileged \
|
||||||
|
--name dockerproxy \
|
||||||
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
|
-v docker-socket:/sockets \
|
||||||
|
-e BIND_CONFIG=/sockets/docker.sock \
|
||||||
|
tecnativa/docker-socket-proxy
|
||||||
|
```
|
||||||
|
|
||||||
|
Once running, the socket can be shared with another container by using the
|
||||||
|
`docker-socket` volume:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ docker container run -v docker-socket:/var/run ...
|
||||||
|
```
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
All the dependencies you need to develop this project (apart from Docker itself) are
|
All the dependencies you need to develop this project (apart from Docker itself) are
|
||||||
|
@ -1,21 +1,23 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Normalize the input for DISABLE_IPV6 to lowercase
|
if [ "${BIND_CONFIG}" = "" ]; then
|
||||||
DISABLE_IPV6_LOWER=$(echo "$DISABLE_IPV6" | tr '[:upper:]' '[:lower:]')
|
# Normalize the input for DISABLE_IPV6 to lowercase
|
||||||
|
DISABLE_IPV6_LOWER=$(echo "$DISABLE_IPV6" | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
# Check for different representations of 'true' and set BIND_CONFIG
|
# Check for different representations of 'true' and set BIND_CONFIG
|
||||||
case "$DISABLE_IPV6_LOWER" in
|
case "$DISABLE_IPV6_LOWER" in
|
||||||
1|true|yes)
|
1|true|yes)
|
||||||
BIND_CONFIG=":2375"
|
BIND_CONFIG=":2375"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
BIND_CONFIG="[::]:2375 v4v6"
|
BIND_CONFIG="[::]:2375 v4v6"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
# Process the HAProxy configuration template using sed
|
# Process the HAProxy configuration template using sed
|
||||||
sed "s/\${BIND_CONFIG}/$BIND_CONFIG/g" /usr/local/etc/haproxy/haproxy.cfg.template > /usr/local/etc/haproxy/haproxy.cfg
|
sed "s#/\${BIND_CONFIG}#$BIND_CONFIG#g" /usr/local/etc/haproxy/haproxy.cfg.template > /usr/local/etc/haproxy/haproxy.cfg
|
||||||
|
|
||||||
# first arg is `-f` or `--some-option`
|
# first arg is `-f` or `--some-option`
|
||||||
if [ "${1#-}" != "$1" ]; then
|
if [ "${1#-}" != "$1" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user