Skip to main content

Docker

Docker is a platform for containerization. In simple terms, it allows us to package an application and all its dependencies into a single, portable unit called a container

 Docker is a container that can run on any OS (platform independent ) 

We can develop the entire application within the Docker container, and that container can run anywhere 

example: developer1 developed his entire software in Docker container with  PHP (Backend) , MySQl and JAva for both backend and front end  developer 2 can get the container from developer 1 the docker container and run without any dependencies and without wasting their time on creating the environment .





Advantages of Docker:

  • Portability:
    • Docker containers ensure that applications run consistently across different environments, from development to production. This eliminates the "it works on my machine"  problem.  
  • Resource Efficiency:
    • Docker containers are lightweight compared to traditional virtual machines, allowing for better resource utilization.
  • Isolation:
    • Containers provide isolation, preventing applications from interfering with each other and enhancing security.
  • Scalability:
    • Docker simplifies scaling applications by allowing you to easily create and manage multiple container instances.
  • Faster Deployment:
    • Docker streamlines the deployment process, enabling faster and more consistent deployments.
  • Consistency:
    • Docker allows for the creation of consistent environments throughout the software development life cycle.

Disadvantages of Docker:

  • Security Concerns:
    • Docker containers share the host OS kernel, which can create security vulnerabilities if not properly managed.
    • Vulnerabilities within Docker images themselves can also pose a threat.
  • Complexity:
    • Managing complex Docker environments, especially at scale, can be challenging.
    • Orchestrating containers with tools like Kubernetes adds another layer of complexity.
  • Performance Overhead:
    • While lightweight, Docker containers do introduce some performance overhead compared to running applications directly on the host OS.
  • Persistent Data Storage:
    • Managing persistent data in Docker containers requires careful planning and configuration.
  • Networking complexities:
    • Setting up and managing complex network configurations between multiple containers can be difficult.

after installing and open 





and to check its working properly in cmd give docker --version , docker info to display all the images .

To understand docker :

Key Concepts:

  • Dockerfile:
    • A Dockerfile is a text file containing instructions for building a Docker image. It defines the base image, adds application code, sets environment variables, and specifies other configurations.
  • Docker Registry:
    • A Docker registry is a storage and distribution system for Docker images. Docker Hub is the most popular public registry, with a vast collection of pre-built images. You can also create private registries.
  • Docker Hub:
    • This is the default public registry. It contains a very large number of premade docker images.

Docker image is the temple contains everything to build the software , immutable , Docker images are built in layers. Each layer represents a set of changes. This layered architecture optimizes storage and makes image distribution efficient




software application  converted into  docker image 


Docker image is created in your system and put into the docker hub 



Pull Docker \Download the docker image :

go to cmd and give docker pull hello-world   hello-world id the image 


you can see the pulled  docker image in the docker application under images 
and also by using docker images in cmd 



To run the docker 

cmd --> docker run image name 



or in GUI under actions --> run 





inorder to run creating the container 

run and output came in the logs 



for each run, a new container is created. we run two times, one in GUI and another in CMd, so two containers were created.


common command :


to list the container : docker ps -a 

ps --> list of container 
a --> all 


To create the simple Docker image :

in order to create a new Dockerfile, go to any IDE, I went to PyCharm and just create the project and file, and named the file as Dockerfile, and D must be in caps. after it automatically ask to install the plugin 
by just downloading the plugin we can create the environment for Dockerfile .

inorder to run the Docker file, we need a lightweight Linux env image is alphine is available 

# alphine is the liunx image available in docker we pull using FROM
FROM alpine:latest
# CMD is the command and echo is to display a line of text or strings that are passed to it as arguments
CMD["echo","Hello","Docker!"]


save the docker file and run 





To build the docker image using dockerfile 

before make sure the docker file is in the directory /path 







and go to terminal inside the IDE 

and give docker build -t my-app:latest in correct path and run 

explanation :

docker build:

  • This is the core command that initiates the Docker image build process.

2. [OPTIONS]:

  • These are optional flags that modify the build process. Some of the most frequently used options are:
    • -t, --tag name[:tag]:
      • Assigns a name and optional tag to the image.
      • Example: docker build -t my-app:latest . (names the image "my-app" and tags it "latest").
    • -f, --file PATH/Dockerfile:
      • Specifies the path to the Dockerfile. If not provided, Docker assumes the Dockerfile is in the build context directory.
      • Example: docker build -t my-app:v1 -f ./my-dockerfiles/Dockerfile .
    • --no-cache:
      • Disables the use of cached intermediate layers during the build. This is useful for ensuring a fresh build.
      • Example: docker build --no-cache -t my-app:latest .
    • --build-arg <varname>=<value>:
      • Sets build-time variables.
      • Example: docker build --build-arg VERSION=1.2.3 -t my-app .

3. PATH | URL | -:

  • This specifies the build context:
    • PATH: A local path to a directory containing the Dockerfile and any files the Dockerfile needs. The . (dot) represents the current directory.
    • URL: A Git repository URL.
    • -: Reads the Dockerfile from standard input.


To Check whether the Docker image was created properly : 
go to docker application --> check under images .
my app image which we created was there.


click action button to check its runs properly 



created docker container and runs properly .:)




























Comments

Popular posts from this blog

session 19 Git Repository

  🔁 Steps to Create a Branch in Databricks, Pull from Git, and Merge into a Collaborative Branch Create a New Branch in Databricks: Go to the Repos tab in your workspace. Navigate to the Git-linked repo. Click the Git icon (or three dots ⋮) and choose "Create Branch." Give your branch a name (e.g., feature-xyz ) and confirm. Pull the Latest Changes from Git: With your new branch selected, click the Git icon again. Select “Pull” to bring the latest updates from the remote repository into your local Databricks environment. Make Changes & Commit: Edit notebooks or files as needed in your branch. Use the "Commit & Push" option to push changes to the remote repo. Merge into the Collaborative Branch: Switch to the collaborative branch (e.g., dev or main ) in Git or from the Databricks UI. Click "Pull & Merge" . Choose the branch you want to merge into the collaborative branch. Review the c...

Session 18 monitering and logging - Azure Monitor , Log analytics , and job notification

 After developing the code, we deploy it into the production environment. To monitor and logging the jobs run in the real time systems in azure  we have scheduled the jobs under the workflow , we haven't created any monitoring or any matrics . After a few times, the job failed, but we don't know because we haven't set up any monitoring, and every time we can't navigate to workspace-> workflows, under runs to see to check whether the job has been successfully running or not and in real time there will be nearly 100 jobs or more jobs to run  In real time, the production support team will monitor the process. Under the workflow, there is an option called Job notification. After setting the job notification, we can set a notification to email . if we click the date and time its takes us to the notebook which is scheduled there we can able to see the error where it happens . order to see more details, we need to under Spark tab, where we have the option to view logs ( tha...

Transformation - section 6 - data flow

  Feature from Slide Explanation ✅ Code-free data transformations Data Flows in ADF allow you to build transformations using a drag-and-drop visual interface , with no need for writing Spark or SQL code. ✅ Executed on Data Factory-managed Databricks Spark clusters Internally, ADF uses Azure Integration Runtimes backed by Apache Spark clusters , managed by ADF, not Databricks itself . While it's similar in concept, this is not the same as your own Databricks workspace . ✅ Benefits from ADF scheduling and monitoring Data Flows are fully integrated into ADF pipelines, so you get all the orchestration, parameterization, logging, and alerting features of ADF natively. ⚠️ Important Clarification Although it says "executed on Data Factory managed Databricks Spark clusters," this does not mean you're using your own Azure Databricks workspace . Rather: ADF Data Flows run on ADF-managed Spark clusters. Azure Databricks notebooks (which you trigger via an "Exe...