Simple image used to perform automatic attach/detach of docker networks to specific containers.
The main use case is collaboration with the well-known docker image jwilder, whose limitation is that it is always necessary to use the "Bridge" network or to know the defined networks in advance.
In the case of development environments managed by several developers, knowing the networks beforehand may not be feasible, whereas the use of "private" networks created for example with a docker-compose.yml file is now standard.
As a compromise, it is possible to use this "sidecar" image that will connect the container-proxy "jwilder-proxy" (the name does not have to be this) with the new networks at runtime, rather than removing the destroyed networks.
Another use case is when using images to be used as "bastions" or simply as "ssh tunnels" to containers in the environment: similarly to the above, it will also be possible to connect networks to these images at runtime, and run specific commands on them.
NOTE: this case is convenient if the image already has commands to perform the 'bulk' update action.
This image can update automagically because uses docker events system, which is ensured via docker socket.
So, to use this image you can run via docker run, but I prefer to use docker in combination to docker-compose,
for example by using this docker-compose.yml file:
version: "3"
services:
server:
image: enomis/sidecar-custom
volumes:
- /<local.path>/docker.sock:/var/run/docker.sock
environment:
SIDECAR_NETWORK_TARGETS: "proxy-jwilder|cmd: nginx -s reload, other-images"
and execute via
docker-compose up -d server
where you can note:
/<local.path>/docker.sock to container path /var/run/docker.sockSIDECAR_NETWORK_TARGETS, environment variable, in details:
,) separated|), in particular:
cmd part is the command that should be runned into related container after network attach/detach **** for example nginx -s reload to force re-update in jwilder/nginx-proxy container.
Here the environment variables used from this image:
| ENVIRONMENT | DEFAULT VALUE | DESCRIPTION |
|---|---|---|
| SIDECAR_NETWORK_TARGETS * | - | Configuration to specify target containers to which networks can be connected/removed |
| SIDECAR_DEBOUNCE_EXECUTION_TIME | empty | Debounce value in seconds, to avoid huge processing. |
| SIDECAR_DEFAULT_LOG_LEVEL | empty | Python Log library levels. See below. |
* required
As you can see, the SIDECAR_NETWORK_TARGETS is mandatory and shoul be setted as explained in previous sections.
Log levels Table:
| LEVEL | Numeric Value |
|---|---|
| CRITICAL | 50 |
| ERROR | 40 |
| WARNING | 30 |
| INFO | 20 |
| DEBUG | 10 |
| NOTSET | 0 |
for more details see the official documentation.
For debugging you can use the follows yaml file:
version: "3"
services:
sidecar:
build:
context: ./
image: enomis/sidecar-custom
server:
image: enomis/sidecar-custom
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
SIDECAR_NETWORK_TARGETS: "jwilder-proxy|cmd: nginx -s reload, another-container-name"
exec:
image: enomis/sidecar-custom
volumes:
- ./:/usr/src/app
- /var/run/docker.sock:/var/run/docker.sock
environment:
SIDECAR_NETWORK_TARGETS: "jwilder-proxy|cmd: nginx -s reload, another-container-name"
command: "sh"
test:
image: enomis/sidecar-custom
volumes:
- ./:/usr/src/app
- /var/run/docker.sock:/var/run/docker.sock
environment:
SIDECAR_NETWORK_TARGETS: "jwilder-proxy|cmd: nginx -s reload, another-container-name"
SIDECAR_DEFAULT_LOG_LEVEL: 10
command: "./test.py"
to run test.py, simply:
docker-compose run test
to access into image:
docker-compose run exec
Content type
Image
Digest
Size
23.5 MB
Last updated
over 4 years ago
docker pull enomis/sidecar-custom