You can communicate with docker from inside the container using a unix socket via the Docker Remote API:
https://docs.docker.com/engine/reference/api/docker_remote_api/
In the container, you can find out the shortedned docker code by looking at $HOSTNAME env var. According to the document, there is a small chance of a collision, I think that for a small number of containers you have nothing to worry about. I do not know how to get the full identifier directly.
You can check the container in the same way as stated in banyan's answer:
GET /containers/4abbef615af7/json HTTP/1.1
Answer:
HTTP/1.1 200 OK Content-Type: application/json { "Id": "4abbef615af7...... ", "Created": "2013.....", ... }
Alternatively, you can pass the docker id to a container in the file. The file is on the "mounted volume", so it is transferred to the container:
docker run -t -i -cidfile /mydir/host1.txt -v /mydir:/mydir ubuntu /bin/bash
The docker identifier (abbreviated) will be in the file / mydir / host 1.txt in the container.
Jiri Jan 08 '14 at 16:15 2014-01-08 16:15
source share