Uh oh!
There was an error while loading. Please reload this page.
Use labels instead of names to identify containers - #1356
Conversation
There was a problem hiding this comment.
Not very familiar with python, but does this currently require to inspect every container, or the containers after filtering by project (and service name)? Trying to determine how important moby/moby#11943 is for this.
There was a problem hiding this comment.
Only the containers after filtering, so it's not so bad
There was a problem hiding this comment.
Ah thanks, I was expecting that, but wasn't sure 😄
aanand
commented
Apr 27, 2015
Fantastic stuff, thank you. Will merge once docker-py label support has landed. |
aanand
commented
Apr 27, 2015
Will this be backwards-compatible with existing Compose projects? i.e. if I've got containers running that I started with the current stable version, then I upgrade and run |
thaJeztah
commented
Apr 27, 2015
Hm, perhaps interesting thought to add the version of compose that was used to create the containers as a label as well, in case there's some migration needed in future. |
dnephin
commented
Apr 27, 2015
Ah, good point. I think that might be a problem. I suspect it will look for containers using labels, find none, then attempt to create them, running into a 409 conflict error from docker. I think we'll need to do something to address that. We could release one version that falls back to trying to lookup by name, or Both of those run into the issue where it requires users to upgrade one version at a time though, skipping the intermediate version would still break things. Another option, which is usually my preference, is to provide a migration script, which would read a
@thaJeztah I think a compose version label would be a good idea |
aanand
commented
Apr 29, 2015
Perhaps if defcontainers(self, *args, **kwargs):
containers=self._containers_using_labels(*args, **kwargs)
ifnotcontainers:
self._check_for_old_containers()
returncontainersdef_check_for_old_containers(self):
containers=self._containers_using_names()
ifcontainers:
names= [c.nameforcincontainers]
raiseUserError(
""" Found containers that were created using an old version of Compose: {} You have two options: - Migrate them with `docker-compose migrate-containers-1.3` - Remove them with `docker rm -f {}` """.format("\n".join(names), " ".join(names))
) |
aanand
commented
Apr 29, 2015
This would mean checking for containers would still be potentially slow when there aren't any in the current project, but compared to how slow it is now we're only adding a single API call (doing a We can remove it in a later version once we're satisfied that most people have upgraded. |
thaJeztah
commented
Apr 29, 2015
@aanand I like that idea. If compose had a configuration file ( (Docker itself is working on some changes in the config files / structure) |
ahmetb
commented
May 6, 2015
@dnephin liked the idea a lot. Does this PR remove service name entirely from the container name or still keep it around? I guess for readability of 'docker ps' output it might be nice to have them. How do the labels on the containers look like when containers are started from |
aanand
commented
May 7, 2015
We keep container names, but they're now "write-only" - we don't look at them, except to figure out what the next numeric suffix should be. (I think eventually we should drop numeric suffixes in favour of something random, so that generating the next one doesn't involve an API call). Also, once this is merged, we'll be able to implement support for specifying custom container names. For that reason, it might make sense to revisit the output of
Something like this: |
thaJeztah
commented
May 7, 2015
Or even a "Project" column; compose should now be able to get all containers that are managed by compose (filter by |
aanand
commented
May 8, 2015
True - we can just look at the labels - but it's still an extra API call versus generating something random.
That might be cool: |
thaJeztah
commented
May 8, 2015
Yes! Thinking if we should keep track of the location of the yaml file where the project was started from (the project "home" directory) |
aanand
commented
May 8, 2015
Actually, yes, that's a good idea and one I meant to suggest earlier: |
thaJeztah
commented
May 8, 2015
Think that should be the location of the config (yaml), now that all paths are relative to that file (iirc), but yeah, something like that. On a side-note, there's a breaking change being worked on in Docker currently. I'm personally not really happy about that. Not sure if compose itself is affected directly, but compose users definitely, if they use bind-mounted volumes to mount their source code during development. See: |
1 similar comment
thaJeztah
commented
May 8, 2015
Think that should be the location of the config (yaml), now that all paths are relative to that file (iirc), but yeah, something like that. On a side-note, there's a breaking change being worked on in Docker currently. I'm personally not really happy about that. Not sure if compose itself is affected directly, but compose users definitely, if they use bind-mounted volumes to mount their source code during development. See: |
3926353 to
7b66f5eComparednephin
commented
May 9, 2015
I'm thinking |
fe07044 to
c5abf9eComparednephin
commented
May 9, 2015
We don't actually have access to the config path from I've added the compose version, that was easy enough. I'm going to focus on migration and backwards compatibility. |
aanand
commented
May 9, 2015
👍 |
c5abf9e to
50fdb00ComparethaJeztah
commented
May 9, 2015
Fully agree! one step at a time, no need to mingle multiple features into one. |
0335def to
3c741c1Comparednephin
commented
May 11, 2015
Alright, migration test added, and appears to be passing. There was actually a bug in the previous version, it would try to add labels to all projects, instead of just the current one. |
thaJeztah
commented
May 11, 2015
True, not a big issue I think, as long as the docs mention it's a temporary method. The migration is a nice extra and will only be used once for a project, so "shrugs" Changes look good to me (but again, I'm not a python coder, so just a general "feel" by glancing over it). I think what's remaining is;
Again, great work! |
aanand
commented
May 11, 2015
Definitely not. |
thaJeztah
commented
May 11, 2015
👍 definitely worth a mention in the docs. People will try, which is fine, but it should be clear that they're on their own in that case. |
There was a problem hiding this comment.
Is it ever expected/OK for a container not to have a number label? I feel like we should error out if we don't find one, unless I've missed a case. Same for the service label.
aanand
commented
May 15, 2015
@moxiegirl@fredlf - your opinions on docs would be useful here. For context, we're making a change to Compose that means people will need to migrate their containers to a new format - but we're only going to keep it around for one version before dropping support for old containers. Compose will show a warning if it detects old-style containers, prompt you to run My question is: where should the document go? We don't plan to keep it around for a long time, so perhaps docs.docker.com isn't the right place and it should just go in a Markdown file on GitHub. |
moxiegirl
commented
May 17, 2015
@aanand My recommendations would be:
I would recommend the section in the release notes would only exist if we know there can be confusion. So, if no issues exist in the next release, the section goes away. For the Upgrade Compose section in the install --- that would remain a stable touchpoint even if it has a single line to rerun the Unfortunately, I have no cycles this release to add the section to install, if you agree and want to add it, I'll have time to review. |
aanand
commented
May 18, 2015
@moxiegirl Thanks - I'll do that. I've opened an issue for it: #1425 |
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
3c741c1 to
6e98decCompareSigned-off-by: Daniel Nephin <dnephin@gmail.com>
6e98dec to
62059d5Comparednephin
commented
May 18, 2015
Rebased, and added an error to |
aanand
commented
May 18, 2015
LGTM |
Use labels instead of names to identify containers
thaJeztah
commented
May 18, 2015
Great job guys! Thanks |
funkyfuture
commented
May 18, 2015
bravo! 👯 💃 👯 (only a matter of gusto atm, but shouldn't anything that is used package-wide like the constants in |
Resolves#1066
Should be compatible with #1269
Also includes:
create_containerandnext_container_number(). I moved the logging intocreate_container()instead of having it happen in all the callers, and changed it so thatfind_next_number()only happens once.