Configuring Docker through Ansible

- name:
hosts: all
tasks:
- name: Docker Repo
yum_repository:
name: docker_repo
description: Repo for Docker
baseurl:
https://download.docker.com/linux/centos/7/x86_64/stable
gpgcheck: false
- name: docker installation
package:
name: "docker-ce-18.09.1-3.el7.x86_64"
state: present
- name: Start docker
service:
name: "docker"
state: started
enabled: yes
- name: docker sdk
command: pip3 install docker
- name: pull image
docker_image:
name: httpd
source: pull
- name: create a folder
file:
path: "/root/etc/ansible/ansibleplaybook/mycode
state: directory
- name: copy
copy:
dest: "/var/www/html/"
src: abhi.html
- name: launch container
docker_container:
name: httpd_webserver
state: started
exposed_ports: "80"
image: httpd
ports: 8080:80
volumes: /var/www/html/:/usr/local/apache2/htdocs
command: httpd -D FOREGROUND
ansible-playbook <filename.yml>

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store