# Buggy code
def _get_container_create_options(
    self, override_options, one_off=False, intermediate_container=None
):
    container_options = dict(
        (k, self.options[k]) for k in DOCKER_CONFIG_KEYS if k in self.options
    )
    container_options.update(override_options)

    container_options["name"] = self._next_container_name(
        self.containers(stopped=True, one_off=one_off), one_off
    )

    # If a qualified hostname was given, split it into an
    # unqualified hostname and a domainname unless domainname
    # was also given explicitly. This matches the behavior of
    # the official Docker CLI in that scenario.
    if (
        "hostname" in container_options
        and "domainname" not in container_options
        and "." in container_options["hostname"]
    ):
        parts = container_options["hostname"].partition(".")
        container_options["hostname"] = parts[0]
        container_options["domainname"] = parts[2]

    if "ports" in container_options or "expose" in self.options:
        ports = []
        all_ports = container_options.get("ports", []) + self.options.get("expose", [])
        for port in all_ports:
            port = str(port)
            if ":" in port:
                port = port.split(":")[-1]
            if "/" in port:
                port = tuple(port.split("/"))
            ports.append(port)
        container_options["ports"] = ports

    if "volumes" in container_options:
        container_options["volumes"] = dict(
            (parse_volume_spec(v).internal, {}) for v in container_options["volumes"]
        )

    if self.can_be_built():
        container_options["image"] = self.full_name
    else:
        container_options["image"] = self._get_image_name(container_options["image"])

    # Delete options which are only used when starting
    for key in DOCKER_START_KEYS:
        container_options.pop(key, None)

    container_options["host_config"] = self._get_container_host_config(
        override_options, one_off=one_off, intermediate_container=intermediate_container
    )

    return container_options


# Traceback (compose.progress_stream.StreamOutputError)
Pulling image 50ff1e85c429:latest...
Pulling repository 50ff1e85c429
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 31, in main
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 21, in sys_dispatch
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 27, in dispatch
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 24, in dispatch
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 59, in perform_command
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 445, in up
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.project", line 183, in up
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.service", line 258, in recreate_containers
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.service", line 243, in create_container
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.progress_stream", line 37, in stream_output
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.progress_stream", line 50, in print_output_event
compose.progress_stream.StreamOutputError: Error: image library/50ff1e85c429:latest not found

# Fixed code
def _get_container_create_options(
    self, override_options, one_off=False, intermediate_container=None
):
    container_options = dict(
        (k, self.options[k]) for k in DOCKER_CONFIG_KEYS if k in self.options
    )
    container_options.update(override_options)

    container_options["name"] = self._next_container_name(
        self.containers(stopped=True, one_off=one_off), one_off
    )

    # If a qualified hostname was given, split it into an
    # unqualified hostname and a domainname unless domainname
    # was also given explicitly. This matches the behavior of
    # the official Docker CLI in that scenario.
    if (
        "hostname" in container_options
        and "domainname" not in container_options
        and "." in container_options["hostname"]
    ):
        parts = container_options["hostname"].partition(".")
        container_options["hostname"] = parts[0]
        container_options["domainname"] = parts[2]

    if "ports" in container_options or "expose" in self.options:
        ports = []
        all_ports = container_options.get("ports", []) + self.options.get("expose", [])
        for port in all_ports:
            port = str(port)
            if ":" in port:
                port = port.split(":")[-1]
            if "/" in port:
                port = tuple(port.split("/"))
            ports.append(port)
        container_options["ports"] = ports

    if "volumes" in container_options:
        container_options["volumes"] = dict(
            (parse_volume_spec(v).internal, {}) for v in container_options["volumes"]
        )

    if self.can_be_built():
        container_options["image"] = self.full_name

    # Delete options which are only used when starting
    for key in DOCKER_START_KEYS:
        container_options.pop(key, None)

    container_options["host_config"] = self._get_container_host_config(
        override_options, one_off=one_off, intermediate_container=intermediate_container
    )

    return container_options