Socat service in Docker based on Alpine Linux
2.9K
Socat proxy based on socat
tool which proxies unix:// socket to tcp:// socket.
This is useful when you need to expose the unix:// socket through
tcp.
Docker daemon through TCPDocker example:
$ docker run \
--rm \
--name socat-docker \
-v /var/run/docker.sock:/var/run/docker.sock:rw \
--network host \
--user root \
binlab/socat
Docker-compose example:
socat-docker:
image: binlab/socat
container_name: socat-docker
hostname: socat-docker
restart: always
user: root
volumes:
- /var/run/docker.sock:/var/run/docker.sock:rw
network_mode: host
And then connect to the Docker:
$ curl http://127.0.0.1:2375/version
You should use root user for run socat inside a container as a
root because my image built to run socat with no privileged user.
In this case is important in that by default docker socket runs
with next permissions:
srw-rw----. 1 root docker 0 Jan 1 00:00 /var/run/docker.sock
Next way is change a permissions for /var/run/docker.sock
Docker networkFor example, this is can be useful when you need to access inside a
Docker of legacy service from a host bonded on unix:// socket.
Docker example:
$ docker run \
--name socat-redis \
-v /tmp/redis.sock:/var/run/docker.sock:rw \
binlab/socat
Docker-compose example:
socat-redis:
image: binlab/socat
container_name: socat-redis
hostname: socat-redis
restart: always
volumes:
- /tmp/redis.sock:/var/run/docker.sock:rw
And then connect to the conteiner:
$ docker run --rm --network docker_default alpine:3.8 nc -v socat-redis 2375
Content type
Image
Digest
Size
3 MB
Last updated
almost 8 years ago
docker pull binlab/socat