-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
docker-compose run command continuously restarting #1013
Comments
Oh dear. Yes, we should probably just override |
Is this something to be fixed upstream as well? Ie, don't allow restart policies on non-detached containers? |
@thaJeztah Assuming the client reattaches, I can see "restart + interactive" being a useful thing in some cases, so probably not. |
@aanand good point, will see if I can test if that actually works. Would probably result in a race condition as well if combined with |
Just checked for Will check some further w.r.t. non-detached and --restart |
Just got the same issue. |
Debugging this with @mbodock, we find out where to override the diff --git a/compose/cli/main.py b/compose/cli/main.py
index 95dfb6c..dbf40f4 100644
--- a/compose/cli/main.py
+++ b/compose/cli/main.py
@@ -325,6 +325,9 @@ class TopLevelCommand(Command):
if options['--entrypoint']:
container_options['entrypoint'] = options.get('--entrypoint')
+ if options['--rm']:
+ container_options['rm'] = options.get('--rm')
+
if options['--user']:
container_options['user'] = options.get('--user')
diff --git a/compose/service.py b/compose/service.py
index 936e3f9..2bfed47 100644
--- a/compose/service.py
+++ b/compose/service.py
@@ -443,7 +443,9 @@ class Service(object):
if isinstance(dns_search, six.string_types):
dns_search = [dns_search]
- restart = parse_restart_spec(options.get('restart', None))
+ restart = None
+ if not options.get('rm', False):
+ restart = parse_restart_spec(options.get('restart', None))
return create_host_config(
links=self._get_links(link_to_self=one_off), The problem now is that if we leave the
Which is strange, as Any thoughts on how we can proceed from here? |
I would try just this: diff --git a/compose/cli/main.py b/compose/cli/main.py
index 95dfb6c..85e6755 100644
--- a/compose/cli/main.py
+++ b/compose/cli/main.py
@@ -325,6 +325,9 @@ class TopLevelCommand(Command):
if options['--entrypoint']:
container_options['entrypoint'] = options.get('--entrypoint')
+ if options['--rm']:
+ container_options['restart'] = None
+
if options['--user']:
container_options['user'] = options.get('--user') Not sure if it'll work, it's just a guess based on what you tried. |
Daniel, your suggestion is even simpler and... It works! :-) Could you please send a PR? |
I probably wont have time to write the tests for it for a little while. If you're interested, feel free to grab the patch and submit a PR! |
Looks like Joseph already took care of it. Thanks Joseph, thanks Daniel! |
This change looks good but should include clear documentation update. |
If we're not going to change it so that I have a use case where I want to detach (because it's a long process—a database restore) but don't want to Looks like I can work around it like this (based on moby/moby#13743 (comment))...
... but for a super-quick process that would be subject to a race condition. |
The restart always on "run" is a little annoying. |
Description of problem:
An unexpected behaviour is encountered when using
docker-compose run
with services definingrestart: always
.docker version
:uname -a
:Linux docker01 3.13.0-45-generic #74-Ubuntu SMP Tue Jan 13 19:36:28 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Environment details :
Host running inside a VMWare VM.
How reproducible:
Use this docker-compose file :
Steps to Reproduce:
Actual Results:
mysql_db_run_1
is still running.Expected Results:
mysql_db_run_1 stopped and removed.
Additional info:
If I don't specify the '--rm' option, the result is the same but without the conflict message.
It looks like
docker-compose run
started the container with 'restart: always' option. I did not find a way to override this behavior from thedocker-compose run
command. Maybedocker-compose run
shall ignorerestart: always
in docker-compose.yml (at least since the--rm
flag has been specified) or provide a way to override this ?The text was updated successfully, but these errors were encountered: