run mysql:5.5 docker image from ansible

How to run mysql: 5.5 from ansible? If I run it directly:

docker run -e MYSQL_ROOT_PASSWORD=pass mysql:5.5

it’s work ok. But if I run from ansible:

  • Bitbucket API version 1
  • Mounting Volumes when using Docker module in Ansible
  • Minor change in ansible playbook does not get updated in target host
  • Is there any way I can automate configuring Nexus 3?
  • cannot connect to docker on RemoteServer using Ansible
  • Docker error resolve host and I/O error on POST request for http://es.example/oauth/check_token Connection refused
  • - name: run database
        module: docker
        image: mysql:5.5
        state: running

    it’s start and immediately stop. Also post in case 1 is 3306/tcp, but in case 2 there is no port.

  • Cgroups and docker - misunderstanding
  • Docker impossible setup sysctl parameter in container RHEL 6.6
  • How to automate multi server deployment using docker
  • How to back up docker swarm mode service configuration for disaster recovery
  • Connect Nginx Docker container to 16 workers
  • JRebel & Docker bean initializing error
  • One Solution collect form web for “run mysql:5.5 docker image from ansible”

    You need to specify mysql root password as environment variable for container. For example:

    - hosts: ansible_host
      gather_facts: False
      sudo: yes
        - name: install pip pkg.
            name: python-pip
            state: present
        - name: install boto pkg.
            name: docker-py
            state: present
        - name: docker
            image: "mysql:5.5"
            state: running
            env: "MYSQL_ROOT_PASSWORD=my-secret-pw"
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.