##### SUMMARY

`docker_container` module often fails because removal of `auto_remove: yes` takes some time. I had the same problem before with shell scripts since `docker stop` returns immediately but container removal takes some time to finish. Until removal is finished, no new container with the same name can be created.

The error message is:

    Error creating container: 409 Client Error: Conflict ("Conflict. The container name "/MYCONTAINER" is already in use by container "HASH". You have to remove (or rename) that container to be able to reuse that name.")

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
docker_container

##### ANSIBLE VERSION
```
ansible 2.9.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/USER/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.17rc1 (default, Oct 10 2019, 10:26:01) [GCC 9.2.1 20191008]

```

##### CONFIGURATION
_no changes_

##### OS / ENVIRONMENT
Ubuntu 19.10


##### STEPS TO REPRODUCE

0. Run playbook to create container
0. Apply many changes to the file system
0. Run playbook again

```yaml
docker_container:
  name: SOMETHING
  image: SOMETHING
  state: started
  detach: yes
  recreate: yes
  autoremove: yes
```

##### EXPECTED RESULTS
Wait for removal before trying to create a new container.


##### ACTUAL RESULTS
Command fails.

```
Error creating container: 409 Client Error: Conflict ("Conflict. The container name "/MYCONTAINER" is already in use by container "HASH". You have to remove (or rename) that container to be able to reuse that name.")
```


#
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
                    'status': ['preview'],
                    'supported_by': 'community'}
DOCUMENTATION = '''
---
module: docker_container
short_description: manage docker containers
description:
  - Manage the life cycle of docker containers.
  - Supports check mode. Run with C(--check) and C(--diff) to view config difference and list of actions to be taken.
version_added: "2.1"
notes:
  - For most config changes, the container needs to be recreated, i.e. the existing container has to be destroyed and
    a new one created. This can cause unexpected data loss and downtime. You can use the I(comparisons) option to
    prevent this.
  - If the module needs to recreate the container, it will only use the options provided to the module to create the
    new container (except I(image)). Therefore, always specify *all* options relevant to the container.
  - When I(restart) is set to C(true), the module will only restart the container if no config changes are detected.
    Please note that several options have default values; if the container to be restarted uses different values for
    these options, it will be recreated instead. The options with default values which can cause this are I(auto_remove),
    I(detach), I(init), I(interactive), I(memory), I(paused), I(privileged), I(read_only) and I(tty). This behavior
    can be changed by setting I(container_default_behavior) to C(no_defaults), which will be the default value from