Skip to content

Cannot use a parameter variable when running docker commands #3320

Open
@subcan

Description

@subcan

I have spent several hours trying to get the following example working

import docker

client = docker.from_env()

# using a list of image strings formatted "<registry>:<image>:<tag>"
for image in images:
    container_id = client.containers.create(image)

This results with the following error:
ERROR - 400 Client Error for http+docker://localhost/v1.48/containers/create: Bad Request ("invalid reference format")

but if I put the exact image string in place of the variable image in the above client.containers.create(image) then it works fine.

I need to be able to iterate through images for my purpose and it seems funny that I have to hard code the parameters used by API?

Any help or advice is appreciated, if this is currently possible

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions