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>

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The Trulinco application will allow your business to stand out confidently in the global business…

Analyzing access logs of WSO2 Identity Server with Elastic Stack

How to use an external API in you Rails app

Coding Efficiently: Tips, Tricks, and Tools to Streamline Workflow

{UPDATE} Tiikeri-simulaattori ja safari-viidakoneläin Hack Free Resources Generator

Raspberry Pi initial configuration

Guest Blog: Does DevOps need the Cloud?

SARVO: The Toughest and Most Unpredictable

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
Abhinav shukla

Abhinav shukla

More from Medium

Ansible troubleshooting — VMware Failed to Import PyVmomi

Fork vs Serial in Ansible

Register Gitlab Runners with Ansible

Task 14.2 and 14.3