Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running one-off containers does not work in 1.3, "is already in use" #1609

Closed
kevinsimper opened this issue Jun 28, 2015 · 12 comments
Closed
Assignees
Labels
Milestone

Comments

@kevinsimper
Copy link

I used to run tests in docker by running one-off containers, but that is not possible in 1.3.

When i try i says

$ docker-compose run backend npm test
Conflict. The name "app_backend_run_1" is already in use by container e46cb8f520ad. You have to delete (or rename) that container to be able to reuse that name.

Same commando that I used before.

I have tried running docker-compose up and also docker-compose migrate-to-labels

How do you run one-off containers, like the docs propose
https://github.com/docker/compose/blob/master/docs/cli.md#run

@dnephin
Copy link

dnephin commented Jun 28, 2015

Unfortunately I don't think the migration removes the one off containers. You'll have to run docker rm app_backend_run_1 to remove the container first.

@kevinsimper
Copy link
Author

But then the docs should be changed, because that does not say anything about that.

And what should be the reason that you can not launch a container that will have another cmd, and have the other still running? That was how it was working before.

@c0
Copy link

c0 commented Jun 30, 2015

I have the same issue. docker rm app_backend_run_1 works one time, but then the next time it increments the number to app_backend_run_2. So I have to run docker rm again and again.

@willbarrett
Copy link

Yeah, I'm seeing the same issue here. It's pretty terrible for development, TBH. TDD in this environment is really frustrating. Development environment standardization is 99% of the reason our organization is using docker - we need to be able to run tests with a single command.

@aanand
Copy link

aanand commented Jul 2, 2015

If you're getting it repeatedly it's because you've got multiple *_run_* containers sitting around (_1, _2, _3 etc) from before the transition to labels. If you remove them all, the error should go away for good.

Perhaps we should detect one-off legacy containers and add another instruction to the help message. Something like:

As of Compose 1.3.0, containers are identified with labels instead of naming convention. If you want to continue using these containers, run:

    $ docker-compose migrate-to-labels

Alternatively, remove them:

    $ docker rm -f myapp_web_1 myapp_redis_1

You should also remove your one-off containers:

    $ docker rm -f myapp_web_run_1 myapp_web_run_2 myapp_web_run_3

@c0
Copy link

c0 commented Jul 2, 2015

I've migrated to labels and docker rm'd all of the one-off containers (e.g. docker rm myapp_web_run_1) and this works as expected for a while.

Then around 20 times I start getting Conflict. The name "myapp_run_21" is already in use. So I rm myapp_run_{1-21} and it's fine for a while. It keeps coming back though.

Anything I can provide to help debug this?

@dnephin
Copy link

dnephin commented Jul 3, 2015

hmm, that is unexpected.

@c0 (or anyone else experiencing this problem) It'd be great to get something like this (before doing the rm) to help debug it:

docker ps -a | grep myapp_web_run | awk '{ print $1 }' | xargs docker inspect -f '{{.Name}} {{.Config.Labels}}'

@aanand
Copy link

aanand commented Jul 3, 2015

See #1643.

@aanand aanand modified the milestones: 1.3.1, 1.3.2 Jul 3, 2015
@aanand aanand removed the in progress label Jul 8, 2015
@c0
Copy link

c0 commented Jul 8, 2015

@dnephin It took a while for the error to return, but it did start happening on run # 31. When I ran your command, it shows over 2,500 containers ?!

Full dump: https://gist.github.com/c0/59e9b385bf47648b31ce

@aanand
Copy link

aanand commented Jul 8, 2015

@c0 it looks like you've simply accrued a vast number of containers over time from running docker-compose run a lot. If you remove them all, you'll stop getting the error.

@c0
Copy link

c0 commented Jul 8, 2015

@aanand what's the difference in the two sets? The first 30 have labels and the other 2,560 don't? I'm not fully clear on where these came from (< v1.3 of docker compose?)

@dnephin
Copy link

dnephin commented Jul 8, 2015

@c0 yes, I think something must be running an earlier version of compose and creating those container. Maybe a crontab somewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants