Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions fig/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,12 @@ def up(self, project, options):
Usage: up [options] [SERVICE...]

Options:
-d Detached mode: Run containers in the background,
print new container names.
--no-color Produce monochrome output.
--no-deps Don't start linked services.
--no-recreate If containers already exist, don't recreate them.
-d Detached mode: Run containers in the background,
print new container names.
--no-color Produce monochrome output.
--no-deps Don't start linked services.
--no-recreate If containers already exist, don't recreate them.
--allow-insecure-ssl Allow insecure connections to the docker registry.
"""
detached = options['-d']

Expand All @@ -410,10 +411,13 @@ def up(self, project, options):
recreate = not options['--no-recreate']
service_names = options['SERVICE']

pull_options = {x: options[x] for x in options if x in ['--allow-insecure-ssl']}

project.up(
service_names=service_names,
start_links=start_links,
recreate=recreate
recreate=recreate,
pull_options=pull_options
)

to_attach = [c for s in project.get_services(service_names) for c in s.containers()]
Expand Down
4 changes: 2 additions & 2 deletions fig/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ def build(self, service_names=None, no_cache=False):
else:
log.info('%s uses an image, skipping' % service.name)

def up(self, service_names=None, start_links=True, recreate=True):
def up(self, service_names=None, start_links=True, recreate=True, pull_options={}):
running_containers = []

for service in self.get_services(service_names, include_links=start_links):
if recreate:
for (_, container) in service.recreate_containers():
running_containers.append(container)
else:
for container in service.start_or_create_containers():
for container in service.start_or_create_containers(pull_options=pull_options):
running_containers.append(container)

return running_containers
Expand Down
8 changes: 4 additions & 4 deletions fig/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def remove_stopped(self, **options):
log.info("Removing %s..." % c.name)
c.remove(**options)

def create_container(self, one_off=False, **override_options):
def create_container(self, one_off=False, pull_options={}, **override_options):
"""
Create a container for this service. If the image doesn't exist, attempt to pull
it.
Expand All @@ -179,7 +179,7 @@ def create_container(self, one_off=False, **override_options):
except APIError as e:
if e.response.status_code == 404 and e.explanation and 'No such image' in str(e.explanation):
log.info('Pulling image %s...' % container_options['image'])
output = self.client.pull(container_options['image'], stream=True)
output = self.client.pull(container_options['image'], stream=True, insecure_registry=pull_options['--allow-insecure-ssl'])
stream_output(output, sys.stdout)
return Container.create(self.client, **container_options)
raise
Expand Down Expand Up @@ -270,12 +270,12 @@ def start_container(self, container=None, intermediate_container=None, **overrid
)
return container

def start_or_create_containers(self):
def start_or_create_containers(self, pull_options={}, **override_options):
containers = self.containers(stopped=True)

if not containers:
log.info("Creating %s..." % self._next_container_name(containers))
new_container = self.create_container()
new_container = self.create_container(pull_options=pull_options, **override_options)
return [self.start_container(new_container)]
else:
return [self.start_container_if_stopped(c) for c in containers]
Expand Down