Updated recreate_containers to attempt to base intermediate container… · lightsofapollo/fig@62bba16 · GitHub
Skip to content

Commit 62bba16

Browse files
committed
Updated recreate_containers to attempt to base intermediate container's the previous container's image.
Added in additional functionality to reset any entrypoints for the intermediate container and pull/retry handling if the image does not exist. Updated test coverage to check if an container is recreated with an entrypoint it is handled correctly.
1 parent 07f3c78 commit 62bba16

3 files changed

Lines changed: 22 additions & 11 deletions

File tree

‎fig/container.py‎

Lines changed: 5 additions & 1 deletion

‎fig/service.py‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,14 @@ def recreate_container(self, container, **override_options):
141141
if container.is_running:
142142
container.stop(timeout=1)
143143

144-
intermediate_container = Container.create(
145-
self.client,
146-
image='ubuntu',
147-
command='echo',
148-
volumes_from=container.id,
149-
)
144+
intermediate_container_options = {
145+
'image': container.image,
146+
'command': 'echo',
147+
'volumes_from': container.id,
148+
'entrypoint': None
149+
}
150+
intermediate_container = self.create_container(
151+
one_off=True, **intermediate_container_options)
150152
intermediate_container.start()
151153
intermediate_container.wait()
152154
container.remove()
@@ -212,7 +214,7 @@ def _get_links(self):
212214
return links
213215

214216
def _get_container_options(self, override_options, one_off=False):
215-
keys = ['image', 'command', 'hostname', 'user', 'detach', 'stdin_open', 'tty', 'mem_limit', 'ports', 'environment', 'dns', 'volumes', 'volumes_from']
217+
keys = ['image', 'command', 'hostname', 'user', 'detach', 'stdin_open', 'tty', 'mem_limit', 'ports', 'environment', 'dns', 'volumes', 'volumes_from', 'entrypoint']
216218
container_options = dict((k, self.options[k]) for k in keys if k in self.options)
217219
container_options.update(override_options)
218220

‎tests/service_test.py‎

Lines changed: 8 additions & 3 deletions

0 commit comments

Comments
 (0)