saltstack docker_container.running gving module docker has no attribute APIClient

55 views Asked by At

Posting this to hopefully help the next person. On a fresh install of Amazon Linux 2023 and saltstack 3006.4 (Sulfur) I was getting the following error.

          ID: roles_smokeping_container
    Function: docker_container.running
        Name: smokeping-master
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/dockermod.py", line 398, in _get_client
                  ret = docker.APIClient(**client_kwargs)
              AttributeError: module 'docker' has no attribute 'APIClient'
...

The master was freshly reinstalled as a container on this new host (minion) so my first inclination was that it was a problem with the master.

1

There are 1 answers

0
keithpjolley On

Turns out the problem was on the minion. Google pointed me to switching from docker-py to docker but as near as I could tell I didn't have docker-py installed.

I ran the following and it cleared the problem right up:

% sudo /opt/saltstack/salt/bin/pip3 uninstall docker-py
% sudo /opt/saltstack/salt/bin/pip3 install --upgrade docker
% sudo salt-call state.apply
...
          ID: roles_smokeping_container
    Function: docker_container.running
        Name: smokeping-master
      Result: True
     Comment: Created container 'smokeping-master'
     Started: 08:31:55.055322
    Duration: 3515.806 ms
...