dwn icon indicating copy to clipboard operation
dwn copied to clipboard

support tag for plans image?

Open WAY29 opened this issue 3 years ago • 2 comments

Once I try to use tag for image like image: longlone/glimmer:cli, I got a horrible error, it seems that dwn image can't support image tag, and always use latest tag, If dwn can add support for the image tag?

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/docker/api/client.py", line 268, in _raise_for_status
    response.raise_for_status()
  File "/usr/local/lib/python3.9/dist-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http+docker://localhost/v1.40/containers/create?name=dwn_glimmer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/dwn", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/dwn/cli/commands/base.py", line 77, in run
    service = plan.container.run()
  File "/usr/local/lib/python3.9/dist-packages/dwn/plan.py", line 377, in run
    container = self.get_client(). \
  File "/usr/local/lib/python3.9/dist-packages/docker/models/containers.py", line 811, in run
    container = self.create(image=image, command=command,
  File "/usr/local/lib/python3.9/dist-packages/docker/models/containers.py", line 870, in create
    resp = self.client.api.create_container(**create_kwargs)
  File "/usr/local/lib/python3.9/dist-packages/docker/api/container.py", line 430, in create_container
    return self.create_container_from_config(config, name)
  File "/usr/local/lib/python3.9/dist-packages/docker/api/container.py", line 441, in create_container_from_config
    return self._result(res, True)
  File "/usr/local/lib/python3.9/dist-packages/docker/api/client.py", line 274, in _result
    self._raise_for_status(response)
  File "/usr/local/lib/python3.9/dist-packages/docker/api/client.py", line 270, in _raise_for_status
    raise create_api_error_from_http_exception(e)
  File "/usr/local/lib/python3.9/dist-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 400 Client Error for http+docker://localhost/v1.40/containers/create?name=dwn_glimmer: Bad Request ("invalid reference format")

WAY29 avatar May 03 '21 06:05 WAY29

I see plans.version in source code and this option can solve my problem: change image: longlone/glimmer:cli to

image: longlone/glimmer
version: cli

but I think add tag in image option is a better choice, because this conforms to the docker habits

WAY29 avatar May 03 '21 06:05 WAY29

Yeah the version tag is what you want here, but supporting the image:tag format makes sense!

leonjza avatar May 03 '21 06:05 leonjza