How to launch MySQL docker container using Ansible playbook?

0 votes

Hi Guys,

I have configured Ansible in my system. I want to launch one MySQL container using Ansible playbook. How can I do that?

Sep 20 in Ansible by akhtar
• 27,980 points
40 views

1 answer to this question.

0 votes

Hi@akhtar,

You can use docker_container module in your Ansible playbook to launch MySQL container. I have attached one playbook below for your reference.

vars:
  docker_volume: db_data
  docker_network: ansible_net
  db_name: db

- name: "Launch database container"
  docker_container:
    name: "{{ db_name }}"
    image: mysql:5.7
  volumes:
    - "{{ docker_volume }}:/var/lib/mysql:rw"
  restart: true
  networks:
  - name: "{{ docker_network }}"
  alias:
  - "{{ db_name }}"
  env:
    MYSQL_ROOT_PASSWORD: wordpress
    MYSQL_DATABASE: wordpress
    MYSQL_USER: wordpress
    MYSQL_PASSWORD: wordpress
answered Sep 20 by MD
• 64,820 points

Related Questions In Ansible

0 votes
0 answers

How to pull a docker image using Ansible playbook?

Hi Guys, I am new in Ansible. I ...READ MORE

Aug 4 in Ansible by akhtar
• 27,980 points
439 views
0 votes
1 answer

How to create a docker container using Ansible?

Hi@akhtar, You can use the docker_container module in ...READ MORE

answered Sep 20 in Ansible by MD
• 64,820 points
37 views
0 votes
1 answer

How to start a docker container with healthstatus using Ansible?

Hi@akhtar, You can use the docker_container module in ...READ MORE

answered Sep 20 in Ansible by MD
• 64,820 points
49 views
0 votes
1 answer

devops , how to create user using ansible playbook

root doesn't need a password to switch ...READ MORE

answered Jul 16, 2018 in Ansible by Kalgi
• 2,620 points
224 views
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 57,680 points
838 views
0 votes
1 answer

How to create a docker container using Ansible playbook?

Hi@akhtar, You can use the docker_container module in ...READ MORE

answered Aug 7 in Ansible by MD
• 64,820 points
357 views
0 votes
1 answer

How to launch an EC2 instance using Ansible Playbook?

Hi@akhtar, Ansible has one module named ec2. This ...READ MORE

answered Aug 12 in Ansible by MD
• 64,820 points
99 views