Skip to content

add container id access (machine-id, container-id) as files in /etc/#6481

Closed
vbatts wants to merge 2 commits intomoby:masterfrom
vbatts:vbatts-gh3506
Closed

add container id access (machine-id, container-id) as files in /etc/#6481
vbatts wants to merge 2 commits intomoby:masterfrom
vbatts:vbatts-gh3506

Conversation

@vbatts
Copy link
Contributor

@vbatts vbatts commented Jun 17, 2014

Something like access to a UUID, for containers.
#3506

Docker-DCO-1.1-Signed-off-by: Vincent Batts [email protected] (github: vbatts)

Something like access to a UUID, for containers.
moby#3506

Docker-DCO-1.1-Signed-off-by: Vincent Batts <[email protected]> (github: vbatts)
@crosbymichael
Copy link
Contributor

Isnt this a dup of #6457

@vbatts
Copy link
Contributor Author

vbatts commented Jun 17, 2014

@crosbymichael ... someone else at red hat is interested in this too ...

@vbatts
Copy link
Contributor Author

vbatts commented Jun 17, 2014

@crosbymichael hey, so I've broadened the scope a little, not much. This accommodates access to container Name, ID, and the downstream requirements of the /etc/machine-id contents (http://www.freedesktop.org/software/systemd/man/machine-id.html)

@vbatts
Copy link
Contributor Author

vbatts commented Jun 17, 2014

$ /home/vbatts/src/docker/docker/bundles/1.0.0-dev/dynbinary/docker-1.0.0-dev run -it --rm busybox sh
/ # cat /etc/machine-id
03dc4d7ea1d3689cf70e96b4b5331bdc
/ # cat /etc/container-id 
03dc4d7ea1d3689cf70e96b4b5331bdc8cd32c3bca63808c3a1b4d38041b1668
/ # cat /etc/container-name
/drunk_brown
/ #

@SvenDowideit
Copy link
Contributor

I would find this very useful to aid in the manual introspection I do to get containers to orchestrate themselves, but... should this really be in the file system? or should this be done 'properly' via the introspection socket - something like docker whoami

@vbatts
Copy link
Contributor Author

vbatts commented Jun 30, 2014

@SvenDowideit understandable. I'm going on the precedent of systemd's use of /etc/machine-id, for having this in the filesystem. I would not be opposed to a /sys or /proc style transient filesystem for introspection stuff like this. As for running docker whoami, that wouldn't be inside a running container, would it?

@SvenDowideit
Copy link
Contributor

yes, docker whoami would be running inside a container

@vbatts
Copy link
Contributor Author

vbatts commented Jul 2, 2014

@SvenDowideit woah. Is this bind mounting in docker? I'm not opposed to an introspection like this, but seems a little wiley to tailor docker for a limited container access. I would not give a container full access to calling docker. perhaps a trimmed single purpose executable similar to dockerinit, that is bind mounted and can traverse that barrier.

@SvenDowideit
Copy link
Contributor

you can't rely on obscurity by using a cut down binary. 'Properly' will require the socket to be filtered to only give the container info it should have.

makes me think someone should make a libswarm introspection backend that we connect to when docker run --introspect

@ibuildthecloud
Copy link
Contributor

I think if we want introspective capabilities it shouldn't be based on writing files to /etc.

@vbatts
Copy link
Contributor Author

vbatts commented Jul 3, 2014

@SvenDowideit understandable. Though the kind of interaction you're describing is neat, but I'm hoping for a standard way (or place) to get the machine's UUID.

@ibuildthecloud fair. But as I've stated before, this is based on precedent. I'm not describing an open socket to the docker daemon that lives in /etc, but an identification of /etc/container-id is basically the same concept as /etc/hostname which the unix way

@ibuildthecloud
Copy link
Contributor

@vbatts I could live with the idea of machine-id because that's an existing freedesktop standard, it's just the idea of inventing new ones. That sets a precedent I'm not comfortable with. But looking at machine-id, I'm also hesitant because of the various possibilities of how that can be managed. I can see arguments that the machine-id should be generated per imagine, per container, or per invocation (on start). Being that the machine-id is just a guid in a file, it seems like letting the user or image maintainer manage it is not a huge burden and maybe be preferable.

@vbatts
Copy link
Contributor Author

vbatts commented Jul 15, 2014

@crosbymichael and @shykes what do y'all see as acceptable forms of identity?

@thaJeztah
Copy link
Member

@vbatts @ibuildthecloud from the machine-id docs;

Programs may use this ID to identify the host with a globally unique ID in the network

IMO this implies that;

  • An image should not contain a machine-id (committing a container should strip the machine-id)
  • The. machine-id should be generated upon initialisation of the container
  • Each container should have a unique machine-id; each instance should be unique, thus cloning/exporting/importing a container should strip and re-generate the machine-id
  • Stopping/resuming a container should not affect the machine-id
  • Problematic; Moving a container to a different host (how to guarantee that the container is moved, not duplicated)

At least, that's my interpretation.

@SvenDowideit
Copy link
Contributor

@thaJeztah true, and that still makes me think that having an /me remote API that works when you're inside a container and accessing an introspection socket seem well worth it.

@vbatts
Copy link
Contributor Author

vbatts commented Jul 16, 2014

@thaJeztah good points. Thankfully, containers are not portable, images are. And this code does initialize the id on every container run. So even commiting the id file, it would be overwritten on any build or run

@SvenDowideit
Copy link
Contributor

if its in the image, thats bad mkay :)

@vbatts vbatts changed the title machine-id: add container id access add container id access (machine-id, container-id, conatiner-name) Jul 16, 2014
@vbatts
Copy link
Contributor Author

vbatts commented Jul 16, 2014

@SvenDowideit i wouldn't go so far as to say bad. Since it is initialized on every run and build, then presence of the previous value is at best history of the where the image came from (which docker inspect -f '{{.Container}}' <image> already includes as well ...)

@vbatts
Copy link
Contributor Author

vbatts commented Jul 16, 2014

* /etc/machine-id has downstream requirements, accomodate those.
* provide access to the container id

Docker-DCO-1.1-Signed-off-by: Vincent Batts <[email protected]> (github: vbatts)
@vbatts
Copy link
Contributor Author

vbatts commented Jul 16, 2014

removed the /etc/containter-name and a couple of defers.

Presently this will initialize /etc/machine-id and /etc/container-id for containers.

@SvenDowideit
Copy link
Contributor

@vbatts - imo that combined with docker commit is bad - compare it to

mount --bind /sys/docker/id /etc/machine-id - or even fixing systemd to be less ew

@vbatts vbatts changed the title add container id access (machine-id, container-id, conatiner-name) add container id access (machine-id, container-id) Jul 24, 2014
@SvenDowideit SvenDowideit changed the title add container id access (machine-id, container-id) add container id access (machine-id, container-id) as files in /etc/ Aug 5, 2014
@duglin
Copy link
Contributor

duglin commented Sep 11, 2014

What ever happened to the idea of using environment variables for these? Couldn't they be injected into the container during startup? Seems a lot easier than adding files to the FS or counting docker itself being installed in the container to "phone home".

btw - big +1 for the container_id being available within the container. Allowing it to know itself is a good thing for when it/if it ever does need to "phone home". But even in other cases, like something in the container needing to tell someone else who it is (so some kind of correlation could be done) would be good.

@vbatts
Copy link
Contributor Author

vbatts commented Sep 11, 2014

this is still being debated on whether to use an env variable, like in #7685

@crosbymichael
Copy link
Contributor

If we are going to do something for this, #7685 is more like the route that we want to take. Closing this in favor of #7685 so we can focus on that implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants