-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Add restart option to Fig. #594
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,7 +142,7 @@ dns: | |
- 9.9.9.9 | ||
``` | ||
|
||
### working\_dir, entrypoint, user, hostname, domainname, mem\_limit, privileged | ||
### working\_dir, entrypoint, user, hostname, domainname, mem\_limit, privileged, restart | ||
|
||
Each of these is a single value, analogous to its [docker run](https://docs.docker.com/reference/run/) counterpart. | ||
|
||
|
@@ -156,4 +156,6 @@ domainname: foo.com | |
|
||
mem_limit: 1000000000 | ||
privileged: true | ||
|
||
restart: always | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps an an example using |
||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
log = logging.getLogger(__name__) | ||
|
||
|
||
DOCKER_CONFIG_KEYS = ['image', 'command', 'hostname', 'domainname', 'user', 'detach', 'stdin_open', 'tty', 'mem_limit', 'ports', 'environment', 'dns', 'volumes', 'entrypoint', 'privileged', 'volumes_from', 'net', 'working_dir'] | ||
DOCKER_CONFIG_KEYS = ['image', 'command', 'hostname', 'domainname', 'user', 'detach', 'stdin_open', 'tty', 'mem_limit', 'ports', 'environment', 'dns', 'volumes', 'entrypoint', 'privileged', 'volumes_from', 'net', 'working_dir', 'restart'] | ||
DOCKER_CONFIG_HINTS = { | ||
'link' : 'links', | ||
'port' : 'ports', | ||
|
@@ -262,6 +262,8 @@ def start_container(self, container=None, intermediate_container=None, **overrid | |
net = options.get('net', 'bridge') | ||
dns = options.get('dns', None) | ||
|
||
restart = parse_restart_spec(options.get('restart', None)) | ||
|
||
container.start( | ||
links=self._get_links(link_to_self=options.get('one_off', False)), | ||
port_bindings=port_bindings, | ||
|
@@ -270,6 +272,7 @@ def start_container(self, container=None, intermediate_container=None, **overrid | |
privileged=privileged, | ||
network_mode=net, | ||
dns=dns, | ||
restart_policy=restart | ||
) | ||
return container | ||
|
||
|
@@ -376,7 +379,7 @@ def _get_container_create_options(self, override_options, one_off=False): | |
container_options['image'] = self._build_tag_name() | ||
|
||
# Delete options which are only used when starting | ||
for key in ['privileged', 'net', 'dns']: | ||
for key in ['privileged', 'net', 'dns', 'restart']: | ||
if key in container_options: | ||
del container_options[key] | ||
|
||
|
@@ -466,6 +469,22 @@ def get_container_name(container): | |
return name[1:] | ||
|
||
|
||
def parse_restart_spec(restart_config): | ||
if not restart_config: | ||
return None | ||
parts = restart_config.split(':') | ||
if len(parts) > 2: | ||
raise ConfigError("Restart %s has incorrect format, should be " | ||
"mode[:max_retry]" % restart_config) | ||
if len(parts) == 2: | ||
name, max_retry_count = parts | ||
else: | ||
name, = parts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stray comma here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because I don't want the >>> a, = ['hello']
>>> a
'hello'
>>> a = ['hello']
>>> a
['hello'] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, neat. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. name = parts[0] is much clearer. ;) Not a big deal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough :) |
||
max_retry_count = 0 | ||
|
||
return {'Name': name, 'MaximumRetryCount': int(max_retry_count)} | ||
|
||
|
||
def parse_volume_spec(volume_config): | ||
parts = volume_config.split(':') | ||
if len(parts) > 3: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still true? Thinking of
:max_retry
here (or is that to be considered a "single" value? idk)