I'm trying to link a child mongo container to a parent node container using the Docker remote API v1.7.
I see the Links
property in HostConfig which I'm guessing is passed to thePOST /containers/<id>/start
request like
{
"Links": ["<container-name>:<alias>", ...]
}
I don't see how to name the mongo container to use when starting the node container. Is there an API analogy to the CLI -name
flag for docker run
?
Do I need to make a separate GET /containers/<id>/json
request and live with the auto-generated name?
A Docker network lets your containers communicate with each other. If you are running more than one container, you can let your containers communicate with each other by attaching them to the same network.
Docker Engine API (1.41) It is the API the Docker client uses to communicate with the Engine, so everything the Docker client can do can be done with the API. Most of the client's commands map directly to API endpoints (e.g. docker ps is GET /containers/json ).
In the current (1.8) API, the -name
flag is passed as a query string to POST /v1.8/containers/create
– i.e. like this:
POST /v1.8/containers/create?name=redis_ambassador
(POST body left out for brevity)
I figured this out by using Geoffrey Bachelet's excellent suggestion of using socat as a proxy for all of my docker CLI commands using the following commands:
# on one terminal
sudo socat -t100 -v UNIX-LISTEN:/tmp/proxysocket.sock,mode=777,reuseaddr,fork UNIX-CONNECT:/var/run/docker.sock
# on a second terminal
export DOCKER_HOST="unix:///tmp/proxysocket.sock"
Subsequent docker
cli commands will be proxied through socat and their CLI calls will be displayed on the other terminal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With