Posts

Docker Service Stack deployment

Image
To work with Docker service stack deployment we should have an orchestrator either Swarm or Kubernetes. Here, in this post, I will be experimenting with the Docker swarm cluster. Prerequisites Docker installed machine Docker swarm initialized and active Create the manifestation file that describes the task, which will be available in the service definition. We can use the declarative definitions for each service in a YAML file.  Docker Swarm Service Stack Deployment I read the book: Learn Docker - Fundamentals of Docker 19.x , where I found the nice explanation given in the    Let's run the docker swarm visualizer container, which will show the Swarm cluster node status, container service status it will be very clear to understand how the orchestrator capabilities work for Docker containers. docker run -it –d \ -p 8080:8080 \ -v /var/run/docker.sock:/var/run/docker.sock \ dockersamples/visualizer Alternatively, you can use the docker-compose file a...

Creating your Custom Image using Dockerfile

Image
How do you create docker image? There are multiple ways to create new docker images docker commit: creates a new layer (and a new image) from a running container. docker build: performs a repeatable build sequence using dockerfile. docker import: loads a tarball into Docker engine, as a standalone base layer. We don't prefer to use docker import, because the import option can be used for various hacks, but its main purpose is to bootstrap the creation of base images. Working on Docker Custom Image Docker images can be pulled from Docker registries. Docker owns Docker Hub and Docker cloud public repositories where you could find the free images. Docker store is a place where Docker images could be on sale. You can create an image and sell it who need it. Docker client is CLI which allows us to deal with the Docker objects. Docker objects are Docker images, Containers, Network, volumes and services. An image is a read-only template that allows us to create instances in ru...

Python Web Framework Flask App on Docker Container

Image
 Namaste this post is an extension of the Docker image management. In this post, I would like to talk about how the Dockerfile content will work to build the Python web framework using the Flask app. Let's consider a web platform we have multiple choices to use as a web application to run on docker container: Python web app using Flask Node.JS app Web app run with Go For all these program execution structures is similar you must have 'app' folder. Where you can write your web application code. FROM python:3.9.4-alpine COPY requirements.txt / RUN pip3 install -r /requirements.txt COPY . /app WORKDIR /app ENTRYPOINT ["./gunicorn.sh"] Here the base image used as Python3 version with apline which is thinner image. As pip installer will use requirement.txt file to install the dependencies libraries and packages required for running Flask. COPY instruciton used to copy the files from docker host machine to container image. WORKDIR is like cd command. ENTRYPOI...

Docker Private Registry with Frontend UI

Image
Hey! In this DevOps learning post, I've done my experiment on Docker Registry-Server connecting with the docker registry UI as a frontend. To support this Frontend service, we have an Apache HTTP server container used as a docker-registry-frontend image. Docker Registry Server connect with Frontend UI Step 1: Go to the docker hub search for 'docker-registry-frontend' given version Pull the image to your local system. docker pull registry docker pull konkardkleine/docker-registry-frontend:v2 docker images docker network create registry docker network ls Step 2: Create the registry server using a docker container run command which expose the port as 5000 and the network that we have created in the step1. This separate network creation will be easy to isolate with other containers running on the same host. docker run --rm -d -p 5000:5000 --name registry-server \ --network registry To verify the access of registry-server docker logs registry-server -f Step 3:  You ca...

Backup and Recovery, Migrate Persisted Volumes of Docker

Image
 Namaste !! Dear DevOps enthusiastic, In this article I would like to share the experimenting of data that is persistence which we learned in an earlier blog post .  In real world these data volumes need to be backed up regularly and if in case of any disaster we can restore the data from these backups from such volumes   Docker Volumes Backup and Restore This story can happen in any real-time project, The data from the on-premises data center to migrate to a cloud platform. One more option is when Database servers backup and restore to different Private networks on a cloud platform. Here I've tested this use-case on two Vagrant VirtualBox's. One used for backup and other for restore MySQL container. Setting up the Docker MySQL container with Volume Step 1 : Let's create a volume with a name as first_vol: docker volume create first_vol #create docker volume ls #Confirm Step 2: create a container with volume for backup of My SQL Database image docke...

Docker SSHFS plugin external storage as Docker Volume

Image
 Namaste, In this exciting Docker storage volume story, this experiment is going to use two Vagrant VirtualBox. You can also use any two Cloud instances (may be GCP, AWS, Azure etc.,). Where DockerHost is going to run the docker containers and DockerClient box is going to run the SSH daemon.  Docker Volume with External Storage using SSHFS Docker allows us to use external storage with constraints. These constraints will be imposed on cloud platforms as well. The external or Remote volume sharing is possible using NFS.  How to install SSHFS volume? Step-by-step procedure for using external storage as given below : Install docker plugin for SSHFS with all permission is recommended: docker plugin install \ --grant-all-permissions vieux/sshfs Create a Docker Volume docker volume create -d vieux/sshfs \ -o sshcmd=vagrant@192.168.33.251:/tmp \ -o password=vagrant -o allow_other sshvolume3 Mount the shared folder on the remote host: mkdir /opt/remote-volume # In rea...

Docker Volumes - Deep Dive with Use Cases

Image
Understanding  Docker Volumes in-depth with real-time scenarios. Where the MongoDB is the backend tier Database and frontend web application using - Mongo-Express container. Use Case 1: MongoDB container without volume observe what happens to the data. Use Case 2: After attaching volume = persistence - confirm re-create containers data persist  Use Case 3: Database containerversion changes does not impacts the Data persisted Let's start the experiment on data persistance. Docker Volume deep dive - MongoDB persistant  To share the sensitive data we use network isolation, which is already discussed in Docker Networks  post. # Create Network docker network create mynet Now let's use this mynet throughout all our use-case examples. MongoDB Connect to Mongo-express which is a member in the same network so that it can access the database Use Case 1: MongoDB Without any volume - Non Persistence MongoDB Container without any persistance storage : docker run -d --...