Ansible error: KeyError: 'ApiVersion' - docker

I'm using Ansible 1.7 (devel) and Docker 0.9.1 build 3600720, and I'm stuck with this error:
failed: [myapp.com] => {"failed": true, "item": "", "parsed": false}
invalid output was: Traceback (most recent call last):
File "/root/.ansible/tmp/ansible-tmp-1400951250.7-173380463612813/docker", line 1959, in <module>
main()
File "/root/.ansible/tmp/ansible-tmp-1400951250.7-173380463612813/docker", line 693, in main
containers = manager.create_containers(1)
File "/root/.ansible/tmp/ansible-tmp-1400951250.7-173380463612813/docker", line 548, in create_containers
if docker.utils.compare_version('1.10', self.client.version()['ApiVersion']) < 0:
KeyError: 'ApiVersion'
Any ideas? Is there any combination of versions that works? I needed Ansible 1.7 because of the 'running' state that was added for docker containers.

I ran into this issue today and decided to fix it. The gist of the problem is older versions of docker don't have an ApiVersion specified (that or the docker-py package doesn't return it).
I've submitted a pull request to fix this issue in the ansible docker module here: https://github.com/ansible/ansible/pull/7619
Alternatively you could upgrade your docker version to get around it.

I got the same error and this fixed it
$ sudo apt-get install -y python-pip
$ sudo pip install docker-py

As said in a more general answer, use the docker_api_version: auto argument :
- name: Mongo data container
docker:
docker_api_version: auto
name: mongo-primary-dc
image: debian:wheezy
state: present
volumes:
- /data

Related

Docker Container nvidia/k8s-device-plugin:1.9 Keeps Reporting Error

I am trying to setup one small kubenertes cluster on my ubuntu 18.04 LTS server. Now every step is done, but checking the GPU status fails. The container keeps reporting errors:
1. Issue Description
I have done steps by Quick-Start, but when I run the test case, it reports error.
2. Steps to reproduce the issue
exec shell cmd
docker run --security-opt=no-new-privileges --cap-drop=ALL
--network=none -it -v /var/lib/kubelet/device-plugins:/var/lib/kubelet/device-plugins
nvidia/k8s-device-plugin:1.9
check the erros
2020/02/09 00:20:15 Starting to serve on
/var/lib/kubelet/device-plugins/nvidia.sock
2020/02/09 00:20:15 Could not register device plugin: rpc error: code = Unimplemented desc =
unknown service deviceplugin.Registration
2020/02/09 00:20:15 Could
not contact Kubelet, retrying. Did you enable the device plugin
feature gate?
2020/02/09 00:20:15 You can check the prerequisites at:
https://github.com/NVIDIA/k8s-device-plugin#prerequisites
2020/02/09
00:20:15 You can learn how to set the runtime at:
https://github.com/NVIDIA/k8s-device-plugin#quick-start
3. Environment Information
- outputs of nvidia-docker run --rm dlws/cuda nvidia-smi
NVIDIA-SMI 440.48.02 Driver Version: 440.48.02 CUDA Version: 10.2
outputs of nvidia-docker run --rm dlws/cuda nvidia-smi
NVIDIA-SMI 440.48.02 Driver Version: 440.48.02 CUDA Version: 10.2
contents of /etc/docker/daemon.json
contents:
{
"default-runtime": "nvidia",
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
}
}
docker version: 19.03.2
kubernetes version: 1.15.2
Finally I found the answer, hope this post would be helpful for others who encounter the same issue:
For kubernetes 1.15, use k8s-device-plugin:1.11 instead. The version 1.9 is not able to communicate with kubelet.

Hyperledger fabric first network error executing ./byfn.sh: line 175: docker-compose: command not found

I have the following prerequisites node v10.16.3, go v1.8.1 linux/amd64, Docker Podman v1.0.5, Docker-compose 1.24.1. All are included in path. When I execute "sudo ./byfn.sh up" I'm able to generate the crypto certificates without issues- However error "docker-compose: command not found
" comes in Line 175 when docker-compose is executed in NetworkUp. Tried uninstalling Docker and reinstalling and couldnt find anything relevant in stackflow as well - can someone pl bail me out ?
error
./byfn.sh: line 175: docker-compose: command not found
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Additional info
host:
BuildahVersion: 1.6-dev
Conmon:
package: podman-1.0.5-1.gitf604175.module+el8.0.0+4017+bbba319f.x86_64
path: /usr/libexec/podman/conmon
version: 'conmon version 1.14.0-dev, commit: 6ee5ad0285ca12e6c8d0b663d7a8db5323812ef6-dirty'
Distribution:
distribution: '"rhel"'
version: "8.0"
kernel: 4.18.0-80.4.2.el8_0.x86_64
os: linux

docker-compose to Bluemix Failed. “TypeError: string indices must be integers”

I am trying to this tutorial. Tutorial: Creating a multi-container deployment with Docker Compose and IBM Bluemix Container Service
However, an error occurred and I cannot understand what does it mean. Please tell me what is wrong.
Versions:
OS: macOS Sierra
bx version 0.5.3+e1de255-2017-05-17T04:07:46+00:00
Docker version 17.03.1-ce, build c6d412e
docker-compose version 1.11.2, build dfed245
Environment Variables:
DOCKER_HOST=tcp://containers-api.ng.bluemix.net:8443
DOCKER_CERT_PATH=/Users/{myname}/.ice/certs/containers-api.ng.bluemix.net/******
DOCKER_TLS_VERIFY=1
docker-compose.yml
lets-chat:
image: registry.ng.bluemix.net/hiroga/lets-chat
ports:
- "8080"
links:
- mongo
mongo:
image: registry.ng.bluemix.net/hiroga/mongo
expose:
- "27017"
Error
$ docker-compose --verbose up
compose.config.config.find: Using configuration files: ./docker-compose.yml
~~~~~~~~~~
compose.parallel.feed_queue: Pending: set([])
compose.parallel.parallel_execute_iter: Failed: <Service: lets-chat>
compose.parallel.feed_queue: Pending: set([])
ERROR: for lets-chat string indices must be integers
Traceback (most recent call last):
File "docker-compose", line 3, in <module>
File "compose/cli/main.py", line 64, in main
File "compose/cli/main.py", line 116, in perform_command
File "compose/cli/main.py", line 876, in up
File "compose/project.py", line 416, in up
File "compose/parallel.py", line 66, in parallel_execute
TypeError: string indices must be integers
Failed to execute script docker-compose
Any solution or hint is welcome. Thank you.
Is there perhaps something earlier in the output that might hint as to the actual error? (before the last string of compose.parallel.feed_queue: Pending: set([]) messages, maybe?)
Double check the image names (compare vs bx ic images, including the version if it isn't latest).
Other possibilities are - if the last messages above that aren't the feed_queue are dealing with docker attach or docker start, then the deploy may have actually been successful, but docker-compose is very optimistic in how long it defaults to waiting. You can try bumping the timeout with export COMPOSE_HTTP_TIMEOUT=300 or similar to give it a bit more patience to deal with remote servers.
If you check with docker ps -a and docker-compose ps, do those show if the actual containers got started?

importerror:no module name docker.client

I've gotten a question when usde ansible to configurate a docker container.
Here is my ansible playbook:
---
-name: localhost
hosts: localhost
vars:
- ansible_python_interpreter: python
tasks:
- name: busybox test
docker:
image: busybox
name: test
but when I run the file with :
ansible-playbook ad.yml
I got following error:
from docker.client import APIError as DockerAPIError
ImportError: No module named docker.client
no docker.client? I have installed docker-py, but still got this question , how can I fix this ?? h....e....l....p....
I think the problem is caused by the way how I install the ansible. After I reinstall the ansible through python-pip, this problem has been solved successfully.
zypper install python-pip
pip install ansible
use this to solve the problem on suse.

install local docker registry on centos 7

I am trying to install a local docker.io registry on a CentOS 7
machine following the instructions here:
https://github.com/docker/docker-registry#quick-start
I ran (EDITED, just to show docker is running):
# service docker restart && cd && docker run -p 5000:5000 registry
After a few minutes looking at the prompt, I got a bunch of errors like this:
[...]
OSError: [Errno 2] No such file or directory: './registry._setup_database.lock'
[2015-03-06 16:39:11 +0000] [13] [INFO] Worker exiting (pid: 13)
[2015-03-06 16:39:11 +0000] [14] [INFO] Worker exiting (pid: 14)
Traceback (most recent call last):
File "/usr/local/bin/gunicorn", line 11, in <module>
sys.exit(run())
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 74, in run
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 185, in run
super(Application, self).run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 71, in run
Arbiter(self).run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 196, in run
self.halt(reason=inst.reason, exit_status=inst.exit_status)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 292, in halt
self.stop()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 343, in stop
time.sleep(0.1)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 209, in handle_chld
self.reap_workers()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 459, in reap_workers
raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
EDITED:
Details of the system:
docker --version
Docker version 1.3.2, build 39fa2fa/1.3.2
System:
cat /etc/centos-release
CentOS Linux release 7.0.1406 (Core)
uname -a
Linux denis1 3.10.0-123.20.1.el7.x86_64 #1 SMP Thu Jan 29 18:05:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Any ideas what I may be doing wrong?
Where should this file be? './registry._setup_database.lock'
EDITED2:
If I try it on my Ubuntu 14.10 laptop, where I installed a new version of docker via a ppa, then it works:
# Upgraded to docker 1.5 via a ppa package in my Ubuntu laptop:
sudo add-apt-repository ppa:docker-maint/testing
sudo apt-get update
sudo apt-get install docker.io
# pull registry latest
sudo docker pull registry:latest
latest: Pulling from registry
fa4fd76b09ce: Downloading 6.931 MB/197.2 MB 3m10s
1c8294cc5160: Download complete
117ee323aaa9: Download complete
fa4fd76b09ce: Pull complete
fa4fd76b09ce: Download complete
1c8294cc5160: Download complete
117ee323aaa9: Download complete
2d24f826cb16: Download complete
777c3edddace: Download complete
f06997673ad7: Download complete
7eafad9a1f16: Download complete
daa8104aee86: Download complete
418dcd975ba2: Download complete
30bff528d188: Download complete
a4f468439f7f: Download complete
e5a8e33139de: Download complete
024a18254446: Download complete
a68f5599e08a: Download complete
511136ea3c5a: Download complete
Status: Downloaded newer image for registry:latest
Any ideas what should I do to get the same result on my CentOS server?
Is there a more recent docker client I can get for CentOS 6 via yum install?
Disable SELINUX and FireWalld.
SELINUX is preventing execution of certain commands as SUDO which is somehow inhibiting behavior.
Also check FireWallD as well.
Neither of upgrade of docker version or "latest" tag etc will solve your problem, I tried them all... it has to do with SELINUX and/or FireWallD... disable both if you can.
I upgraded docker version to 1.5.0 by adding this to yum.repos.d:
[virt7-testing]
name=virt7-testing
baseurl=http://cbs.centos.org/repos/virt7-testing/x86_64/os/
enabled=1
gpgcheck=0
I feel like we can summarize things like this:
The documentation for 'registry' says it only supports docker 1.5. You're running 1.3 and there's a pretty big jump between these.
Supported Docker versions
This image is officially supported on Docker version 1.5.0.
Support for older versions (down to 1.0) is provided on a best-effort
basis.
On CentOS 6.5, you can yum install docker from EPEL (Docker instructions) and get Docker 1.5. Earlier than 6.5, you must yum install docker-io and it appears that 1.4 is the latest available version from EPEL.
In my experience, Docker's support on RedHat-family systems has been poorer then on Debian-family, but this gap has closed in the most recent versions of RH and Docker.

Resources