Conversation
|
@rhatdan Could you provide image and run command with which I can test this? |
|
nice, I like this approach |
|
@rhatdan You should write integration-cli test. |
|
It will not override an existing /etc/machine-id. So I guess you need to make sure there is no /etc/machine-id in the image, before running. I have not tested this with a systemd container yet. I am just following the example given on the document page. I will look into testing or having someone test this next week to make sure it works properly. (I am on Vacation next week). |
|
is this really so insignificant to not need documentation? |
|
I added some mention of container_uuid to the examples and a line to docker run man page. Do you want this mentioned elsewhere. Not sure we document any other environment variables being set. |
|
ping @shykes What do you think about this proposed change? Are we ready to support letting containers know the ID? |
4d700e2 to
5a533b4
Compare
|
Back from Vacation, updating Pull Requests and seeing if there is anything I can do to move these along. |
docs/man/docker-run.1.md
Outdated
There was a problem hiding this comment.
I think "Container ID" here should be "container ID".
|
LGTM. Ping @jamtur01 |
|
@crosbymichael @shykes this would also close #6481 |
fd6554a to
f207a1e
Compare
|
Docs LGTM |
|
Will there be a way to disable this? I can perfectly imagine that I wouldn't like my processes to know they're running within Docker by checking for the existance of this environment variable; sorry for the pedant minimalism, but I would also not clutter (further) the environment variables with this feature. |
|
Well you could unset container_uuid within the containers init. I think adding an option to stop this would be a waste. |
|
At first, there is still no tests. And I still want to see how this works. |
|
@LK4D4 Added integration test. |
|
What is the magic command to allow me to test only my test? Not the entire test suite? |
|
|
|
hostname makes sense to override, Env container_uuid not so much. |
ab8686a to
519f7d0
Compare
6b308ac to
ecab633
Compare
|
@rhatdan Hello, I just realized that we talking about inside container env, so will not this be the same like: |
|
How about we just set the Docker container ID in a CID envvar ? |
|
I would be okay with adding container_uuid if we also add container_id or something like that so systemd and users can benefit :) but this is just my opinion |
|
I'm fine with making the container's ID available to the application in a well-know and well-supported env variable. It would be strictly better than applications trying to infer it from something that is not fully supported, like the hostname. I think we should avoid the term "uuid" since, technically, the current ID is not a uuid, and even if it were, we reserve the right to change the allocation method later. For example with the new trust primitives, it is likely that each container will have its own encryption keypair, and we could use the public key as an identifier. As far as the application is concerned, all that matters is that there is a single, globally unique string which identifies the container in which it is running. So, I suggest we store the container ID in |
|
I realize that systemd expects the precise variable name Hopefully this makes sense to everyone. It seems like a no-brainer to me. |
|
@shykes true, but what if there were an abstraction that would allow manipulation for a |
|
Turns out there is more to getting systemd wired up correctly then just passing in the container_uuid. I have extended this patch to handle setting up journalling to allow journal inside the container to write messages that the journal outside of the container can see. I have to work on one more patch to setup the machine-ctl to recognise that a there is a container running. docker needs to send the UUID to docker via dbus to make this happen. Once it is fully instrumented then there would be more container information available in the HOST OS, including using machinectl, ps -o machine, journal -M machine etc. |
29931c7 to
2a9dd30
Compare
If you are running with systemd as init 1 and specify the container_uuid environment variable, systemd will create /etc/machine-id with the correct data. Then on the host you can setup journald to watch the container. systemd only allows 32 chars in the UUID stored in /etc/machine-id Then we can later apply a different patch to setup journald to watch containers from the host and log all syslog/stdout/stderr data together int the hosts journal. The following link explains what systemd expects to be setup. http://www.freedesktop.org/wiki/Software/systemd/ContainerInterface/ This should replace moby#3506 Docker-DCO-1.1-Signed-off-by: Dan Walsh <[email protected]> (github: rhatdan)
…content in container Docker-DCO-1.1-Signed-off-by: Dan Walsh <[email protected]> (github: rhatdan)
Docker-DCO-1.1-Signed-off-by: Dan Walsh <[email protected]> (github: rhatdan)
Docker-DCO-1.1-Signed-off-by: Dan Walsh <[email protected]> (github: rhatdan)
|
Review session with @tiborvass @unclejack @crosbymichael Although the PR initially started about "exposing" container ID, the requirements have changed along the way to supporting the systemd journal. We believe with this new information we should take a step back and think about the requirements to support the systemd journal with Docker containers. We're closing the PR as it won't be merged as it is, but discussions can continue here. |
|
This is not unexpected, since if I could not convince you to support setting an Environment Variable within an image, I doubt you would consider mounting /var/lib/journal. Sadly it leaves those of us looking to run systemd correctly within a container little options. |
If you are running with systemd as init 1 and specify the container_uuid environment
variable, systemd will create /etc/machine-id with the correct data.
Then on the host you can setup journald to watch the container.
systemd only allows 32 chars in the UUID stored in /etc/machine-id
Then we can later apply a different patch to setup journald to watch
containers from the host and log all syslog/stdout/stderr data together
int the hosts journal.
The following link explains what systemd expects to be setup.
http://www.freedesktop.org/wiki/Software/systemd/ContainerInterface/
This should replace
#3506
Docker-DCO-1.1-Signed-off-by: Dan Walsh [email protected] (github: rhatdan)