Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

docker_container never starts containers #5774

Closed
gvilarino opened this issue Nov 30, 2016 · 9 comments
Closed

docker_container never starts containers #5774

gvilarino opened this issue Nov 30, 2016 · 9 comments

Comments

@gvilarino
Copy link

ISSUE TYPE
  • Bug Report
COMPONENT NAME

docker_container

ANSIBLE VERSION
ansible 2.2.0.0
  config file = /usr/src/playbooks/ansible.cfg
  configured module search path = Default w/o overrides
CONFIGURATION
OS / ENVIRONMENT
Linux 37059fd9679f 3.13.0-91-generic #138-Ubuntu SMP Fri Jun 24 17:00:34 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
SUMMARY

Containers are created with the wrong name, outside network and never start

STEPS TO REPRODUCE

Run a playbook that does the following:

- name: ensure docker network exists
  docker_network:
    appends: True
    connected:
      - existing_container
    name: my_network
    state: present

- name: ensure new container is running
  docker_container:
    image: mongo:3.2
    name: new-container
    networks:
      - name: my_network
    state: started
EXPECTED RESULTS

A container named new-container running, and in the my_networ network

ACTUAL RESULTS

Container with generic name is Created outside network, not running

ansible -vvvvv output

dockerd -D output

docker ps -a yields:

CONTAINER ID        IMAGE                                            COMMAND                  CREATED             STATUS              PORTS               NAMES
c2d470cdcc51        mongo:3.2                                        "/entrypoint.sh mongo"   21 minutes ago      Created                                 stupefied_pasteur

According to the docker daemon logs, the daemon never gets the /start instruction, just the /create

@ansibot
Copy link

ansibot commented Nov 30, 2016

@ansible ping, this issue is waiting for your response.
click here for bot help

@gitgc
Copy link

gitgc commented Dec 1, 2016

I'm seeing the exact same issue. Container with state "started" creates a container with a generic Docker assigned name instead of one specified in Ansible, and with "created" status instead of running.

I'm running Ansible 2.2.0.0 with docker-py 1.10.6:

- name: Seed tenant database
  docker_container:
    name: "test"
    image: "mydockerhub/image:latest"
    command: "create-tenant"
    labels:
      tenant: "{{ tenant_name }}"
    state: started

results in a Docker container with a generic name like "hungy_tesla" and STATUS of "Created" instead of "Running".

@xiemeilong
Copy link

same issue

@gvilarino
Copy link
Author

As per the links @marcosnils provided, the issue is with docker-py having requests as an unpinned dep, which is broken in the last 2 versions

@gvilarino
Copy link
Author

gvilarino commented Dec 1, 2016

Just install a 2.11.x version of requests and you'll be fine. I'm closing this

@juanluisbaptiste
Copy link

I think you mean 2.11.x, 1.11.x doesn't exist and I just tried with 2.11.1 and works.

@gvilarino
Copy link
Author

Yeah, sorry, @juanluisbaptiste; I stand corrected

@mulakkalfaizal
Copy link

i am facing the same issue.

Using requests (2.11.1)
docker-py (1.10.6)

Fedora 26

any help

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants