salt icon indicating copy to clipboard operation
salt copied to clipboard

dockerng.image_present should allow public repository pulling by default

Open rantoniuk opened this issue 11 years ago • 21 comments

Either I am missing something in the docs, or currently looking at: https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.dockerng.html#docker-authentication it seems that I must provide registry configuration, whereas using normal docker installations I can just pull images from the public registry without any. So, I had to create a pillar and include fake credentials to get going which is counter-intuitive I guess...

docker-registries:
  https://index.docker.io/v1/:
    email: [email protected]
    password: s3cr3t
    username: foofoo

My current workaround for this is to create a Dockerfile with only FROM line and then using:

xxx:
  dockerng.image_present:
    - build: /path/to/Dockerfile

but this is an ugly hack for an obvious behavior :-)

rantoniuk avatar Oct 16 '15 01:10 rantoniuk

@warden, thanks for the report.

jfindlay avatar Oct 16 '15 18:10 jfindlay

Hi guys, I imagine dockerng should also allow unauthenticated image pulls from a private docker registry, not just the official public registry. For folks using local repositories this is a major problem... We had to keep using the docker-formula because we can't find a way to pull images with dockerng. I'd say this is a bug fix, not a feature :)

tiadobatima avatar Oct 21 '15 22:10 tiadobatima

Thanks @jfindlay! :)

tiadobatima avatar Oct 28 '15 18:10 tiadobatima

Same issue here, unauthenticated image pulls should be allowed.

jgelens avatar Oct 29 '15 14:10 jgelens

Is there a workaround to pull images?

mo-mughrabi avatar Nov 02 '15 00:11 mo-mughrabi

I just switched back to the old dockerio module/states for now.

jgelens avatar Nov 02 '15 07:11 jgelens

My workaround is in the bug description.

rantoniuk avatar Nov 02 '15 12:11 rantoniuk

I ended up using this as a workaround until new release is out

prep redis image:
  cmd.run:
    - name: /usr/bin/docker pull redis

mo-mughrabi avatar Nov 02 '15 12:11 mo-mughrabi

+1 on this. Requiring credentials for public repos is both annoying and not intuitive at all.

gravyboat avatar Nov 10 '15 00:11 gravyboat

Ran into this today:

Comment: Encountered error pulling forresta/docka-docka-docka:latest: 500 Server Error: Internal Server Error ("Login: Account is not Active. Please check your e-mail for a confirmation link.")

This makes dockerng.image_present basically worthless to me as I want to host these details on GitHub, I'm going to have to use the cmd.run workaround as well.

gravyboat avatar Nov 10 '15 22:11 gravyboat

+1 It is possible to pull images from public repositories using docker-py directly without specifying credentials. Whatever the SaltStack Dockerng implementation is doing is a self-imposed restriction. I too have had to resort to doing something similar to what @mo-mughrabi is doing.

damnhandy avatar Nov 29 '15 15:11 damnhandy

+1 On salt 2015.8.1 According to dockerng.running document This state will pull the image if it is not present, so I use simple dockerng.running(without dockerng.image_present), but ran into this:

   Function: dockerng.running
        Name: redis_default
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/site-packages/salt/state.py", line 1591, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/site-packages/salt/states/dockerng.py", line 1384, in running
                  image_id = __salt__['dockerng.inspect_image'](image)['Id']
                File "/usr/lib/python2.7/site-packages/salt/modules/dockerng.py", line 2108, in inspect_image
                  ret = _client_wrapper('inspect_image', name)
                File "/usr/lib/python2.7/site-packages/salt/modules/dockerng.py", line 569, in wrapper
                  return wrapped(*args, **salt.utils.clean_kwargs(**kwargs))
                File "/usr/lib/python2.7/site-packages/salt/modules/dockerng.py", line 832, in _client_wrapper
                  exc.explanation)
              CommandExecutionError: Error 404: No such image: sameersbn/redis:latest

I think salt just skip the pull part because it failed in the __salt__['dockerng.inspect_image'] and I don't have the image yet. So I pull with dockerng.image_present first and

Encountered error pulling sameersbn/redis:latest: Missing Docker credentials. Please see the dockerng remote execution module documentation for information on how to configure authentication.

Now I have to use cmd.run as @mo-mughrabi does

7kbird avatar Dec 04 '15 08:12 7kbird

+1

dkiser avatar Jan 11 '16 01:01 dkiser

:+1:

rhansen avatar Jan 26 '16 23:01 rhansen

Hi all! Is anyone on this issue in a position to give #31354 a try? That should resolve this issue. The fix will be available in the 2015.8.8 version of Salt.

rallytime avatar Mar 04 '16 22:03 rallytime

I ran into the same issue as gravyboat, getting that the account is not active. Which is not correct since I'm using an account that is verified. It worked once when I entered bogus details, so it seems like it creates a new account, then realizes its not verified and stops working. Because the absolut first time I created an account on the docker hub site, and entered the details, and salt said this account already exists. No shit sherlock...

Aidenir avatar Mar 22 '16 14:03 Aidenir

@Aidenir This should be fixed in the next(?) release of Salt I think, for the time being you can do this: https://github.com/gravyboat/docka-docka-docka/blob/master/docka-salt/srv/salt/docker/docka.sls#L22

gravyboat avatar Mar 22 '16 18:03 gravyboat

In AWS ERC you setup the docker login credentials on the local machine then you use the normal docker push/pull commands. It looks like docker-py will try and use the docker login credentials on the local machine automatically. As it stands, the below sls will error our because dockerng is requiring credentials. I am wondering if this fix will address my issue as well. My issue goes one step further, in that I need dockerng to try and use the local credentials on the minion.

{% set aws_url=*****05.dkr.ecr.us-east-1.amazonaws.com' %}
#Run docker login with the dynamic credentials from AWS
#Runs docker login -u AWS -p ***IO1F2g37x
aws-erc-login:
  cmd.run:
    - name: $(aws ecr get-login --region us-east-1)

#Hopefully use those credentials to pull the image from the repo
{{aws_url}}/ngs_tester:yetagain:
  dockerng.image_present:
    - require:
      - cmd: aws-erc-login

This would work if dockerng first tried to use the credentials on the local machine.

dockertesting:
----------
          ID: aws-erc-login
    Function: cmd.run
        Name: $(aws ecr get-login --region us-east-1)
      Result: True
     Comment: Command "$(aws ecr get-login --region us-east-1)" run
     Started: 21:06:16.322842
    Duration: 1498.758 ms
     Changes:   
              ----------
              pid:
                  21363
              retcode:
                  0
              stderr:
              stdout:
                  WARNING: login credentials saved in /root/.docker/config.json
                  Login Succeeded
----------
          ID: ******.dkr.ecr.us-east-1.amazonaws.com/ngs_tester:yetagain
    Function: dockerng.image_present
      Result: False
     Comment: Encountered error pulling ****5.dkr.ecr.us-east-1.amazonaws.com/ngs_tester:yetagain: Missing Docker credentials. Please see the dockerng remote execution module documentation for information on how to configure authentication.
     Started: 21:06:17.849639
    Duration: 11.224 ms
     Changes:   

Versions:

Salt Version:
           Salt: 2015.8.7

Dependency Versions:
         Jinja2: 2.7.2
       M2Crypto: Not Installed
           Mako: Not Installed
         PyYAML: 3.10
          PyZMQ: 14.7.0
         Python: 2.7.5 (default, Nov 20 2015, 02:00:19)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.5.0
          gitdb: 0.6.4
      gitpython: 1.0.2
          ioflo: Not Installed
        libgit2: Not Installed
        libnacl: 1.4.4
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: 0.9.0
        timelib: Not Installed

System Versions:
           dist: centos 7.2.1511 Core
        machine: x86_64
        release: 3.10.0-327.10.1.el7.x86_64
         system: CentOS Linux 7.2.1511 Core

mjmonroe avatar Mar 22 '16 21:03 mjmonroe

@gravyboat Great, thanks for the help :)

Aidenir avatar Mar 23 '16 07:03 Aidenir

2015.8.8 is live now, has anyone validated that this issue is resolved?

meggiebot avatar Mar 24 '16 22:03 meggiebot