Search code examples
dockersalt-projectdocker-registry

Pull image from private Docker registry in SaltStack


I want to pull an image from a private Docker registry running on port 5000. It looks like SaltStack's dockerng module isn't liking the image format:

my service:
  dockerng.running:
    - name: some-service
    - image: docker-registry.example.com:5000/path/to/image

Results in this error when applying the state:

      ID: my service
Function: dockerng.running
    Name: some-service
  Result: False
 Comment: Failed to pull docker-registry.example.com:5000/path/to/image: Error 500: {"message":"invalid tag format"}
 Started: 15:30:57.202009
Duration: 24.922 ms

It works fine if I do this from the command line: docker pull docker-registry.example.com:5000/path/to/image. No username/password are required.

Any hints on how to get the state file in the correct format?


Solution

  • From a quick glance at the source code, it seems that Salt will simply assume everything following the rightmost : character to be the image tag (so, in this case, 5000/path/to/image, which is obviously a bad tag name).

    A quick workaround seems to be to just explicitly specify a tag, instead of implicitly using latest:

    my service:
      dockerng.running:
        - name: some-service
        - image: docker-registry.example.com:5000/path/to/image:latest