Docker: Alias command name to run another sibling docker container
I know how to -v the docker socket into a container to make the host’s docker daemon available inside a container. Fine.
I have a dockerized application A that can operate on files on the host.
I have another dockerized application B that wants to use that application A to operate on files on the host, but is hardcoded to call
How do I alias
/usr/bin/A within container B, so that it will call out to the other container, like
docker run -ti --rm A filename
One Solution collect form web for “Docker: Alias command name to run another sibling docker container”
You could just replace
/usr/bin/A in container B with a shell script:
#!/bin/sh docker run -ti --rm A "$@"
You could do this in the image itself (via your
Dockerfile), or you could bin-mount the script when you start container B (
docker run -v /path/to/my/script:/usr/bin/A ...).
Now you run
/usr/bin/A some_filename and it should do the right thing, assuming that you can successfully run
docker inside the container.