Developing web-apps and deploying them on top of docker containers using Ansible Playbooks

pip3 install ansible -y
ansible --version
vim /etc/myhosts.txt
vim /etc/ansible/ansible.cfg
ansible --version
ansible all --list-hosts
- hosts: dockerhost
gather_facts: false
tasks:
- name: conf yum for docker
yum_repository:
name: dockerrepo
baseurl: https://download.docker.com/linux/centos/7/x86_64/stable/
description: my docker repo desc
enabled: true
gpgcheck: 0
- name: install docker software
command: "yum install docker-ce --nobest -y"
- name: start docker services
service:
name: "docker"
state: started
enabled: yes
- name: install software python36
package:
name: python36
state: present
- name: install docker python library
pip:
name: docker-py
- name: pull image from hub
docker_image:
name: httpd:latest
source: pull
- name: run_container
docker_container:
name: myweb
image: httpd:latest
state: started
ports:
- "8082:80"
tty: true
detach: true
ansible-playbook docker.yml
docker ps
docker exec -it myweb /bin/bash
curl 192.168.0.12:8082
curl 192.168.99.103:8082/myapp.html

--

--

--

I am a DevOps Enthusiast and recently taken to Cloud Computing. Learning Flutter App Development currently. In my free time I engage in competitive coding.

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

Recommended from Medium

How-to Debug a Running Docker Container from a Separate Container

D’CENT Wallet Update: Improvements in the Discovery (DApp browser)

The Effects of Public Cloud on Team Autonomy

12 Common mistakes when using Process Metrics

Command-line completion and Helm

Defi3.0 Fort Protocol:The first Infrastructure for Defi Metaverse

Advanced Python — Asynchronous programming

ARP ( Address Resolution Protocol ) demystified

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
Shirsha Datta

Shirsha Datta

I am a DevOps Enthusiast and recently taken to Cloud Computing. Learning Flutter App Development currently. In my free time I engage in competitive coding.

More from Medium

Recipe OSS: How to set back-to-origin rules? (Alibaba Cloud)

How to backup and clone your Jenkins Instance

Create Your First Linux Server on AWS EC2

How to configure Two Node High Availability Cluster On RHEL/CentOS