Posts

Showing posts with the label dockerfile

HEALTHCHECK Instructions in Dockerfile

Image
 Hello Guys in this post I wish to explore more intresting instructions HEALTHCHECK which can be used in Dockerfile.  The most common requirement for any real-time projects monitoring using a side-car container which could run in parallel and try to check the process or application URL check or container reachability using ping command etc.  Dockerfie instruction HEALTHCHECK In Dockerfile we can have HEALTHCHECK instruction that allows us to know the condition of an application test runs as expected or not, when a container runs this will be returns a status as healthy, unhealthy based on the HEALTHCHECK command exit code. If the exit code 0 then returns healthy otherwise unhealthy. HEALTHCHECK [options] CMD [health check command] Example: HEALTHCHECK --interval=3s CMD ping c1 172.17.0.2 here are the Healthcheck options   --interval=time in sec (duration 30s is default)  --timeout=time in sec (duration 30s is default)  --start-period=time in ...

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 Image Management

Image
In this post, we will be discussing docker image creation, management and before jumping into this article if you do not yet install Docker? then, I also recommend you to go through my previous post where I've discussed how to install Docker-CE or Docker EE. I would like to expose most of the things related to Docker Images. Assuming that now you have everything ready! that means Docker engine up and running. What is all about Docker Image? According to docker docs -- An image is an executable package that includes everything needed to run an application -- the code, runtime, libraries, environment variables and configuration files. The runtime of a docker image is called a Docker container. In simple words, an Image is nothing but a stopped container! Let me put my understanding into a picture first and then we explore all these possible syntax and examples. Docker Image Life cycle Let us talk about the docker image that was built with multiple layers. Docke...