ansible-container docker.errors.DockerException: Error while fetching server API version

cucucool picture cucucool · Jul 18, 2018 · Viewed 10.1k times · Source

I am trying to build a container using ansible-container module on my Mac and running into the following issue.

Karthiks-MacBook-Pro:infrastructure karthikjayaraman$ ansible-container   build --roles-path=/Users/karthikjayaraman/roles
Building Docker Engine context...
Starting Docker build of Ansible Container Conductor image (please be patient)...
Parsing conductor CLI args.
Docker™ daemon integration engine loaded. Build starting.   project=infrastructure
Building service... project=infrastructure service=mdcsat
Traceback (most recent call last):
  File "/usr/bin/conductor", line 11, in <module>
    load_entry_point('ansible-container', 'console_scripts', 'conductor')()
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/cli.py", line 399, in conductor_commandline
    **params)
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/core.py", line 700, in conductorcmd_build
    cur_image_id = engine.get_image_id_by_tag(service['from'])
  File "/_ansible/container/docker/engine.py", line 549, in get_image_id_by_tag
    image = self.client.images.get(tag)
  File "/_ansible/container/docker/engine.py", line 164, in client
    self._client = docker.from_env(version='auto', timeout=timeout)
  File "/usr/lib/python2.7/site-packages/docker/client.py", line 80, in from_env
    **kwargs_from_env(**kwargs))
  File "/usr/lib/python2.7/site-packages/docker/client.py", line 37, in __init__
    self.api = APIClient(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/docker/api/client.py", line 147, in __init__
    self._version = self._retrieve_server_version()
  File "/usr/lib/python2.7/site-packages/docker/api/client.py", line 174, in _retrieve_server_version
    'Error while fetching server API version: {0}'.format(e)
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', error(2, 'No such file or directory'))
Conductor terminated. Cleaning up.  command_rc=1 conductor_id=6a4f7bcb46a33b8053d22af2ecc17abaa84abddf99f80f133b921546d36c76fc save_container=False
ERROR   Conductor exited with status 1

The build numbers of the components are as follows:

Karthiks-MacBook-Pro:infrastructure karthikjayaraman$ ansible --version
ansible 2.6.1
  config file = /Users/karthikjayaraman/mdc/mdc/tools/infrastructure/ansible.cfg
  configured module search path = [u'/Users/karthikjayaraman/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Library/Python/2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.10 (default, Oct  6 2017, 22:29:07) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]
Karthiks-MacBook-Pro:infrastructure karthikjayaraman$ docker --version
Docker version 18.03.1-ce, build 9ee9f40
Karthiks-MacBook-Pro:infrastructure karthikjayaraman$ ansible-container version
Ansible Container, version 0.9.2

Docker on my Mac is installed and running well.

Karthiks-MacBook-Pro:infrastructure karthikjayaraman$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Any help appreciated !.

Answer

Voronenko picture Voronenko · Jul 18, 2018

Are you sure, you added your user account to the docker group? (your = account you run ansible-container under)

See here: https://docs.docker.com/engine/installation/linux/linux-postinstall/