Dockerfile - explained

Search for a command to run...

No comments yet. Be the first to comment.
Introduction Argo Workflows is an open-source workflow orchestration tool for Kubernetes. In this tutorial, we will walk through the steps to install Argo Workflows on a Kubernetes cluster and access its server UI. Step 1: Check Current Context Befor...

The Azure CLI is a powerful tool for managing and automating tasks in Azure. To use the Azure CLI, you need to log in to your Azure account. In this blog, we will go over the different methods you can use to log in to Azure using the Azure CLI. Log i...

Connecting to an Azure VM from windows can be a bit tricky and you may get errors like WARNING: UNPROTECTED PRIVATE KEY FILE! Permissions for ' ' are too open, It is required that your private key files are NOT accessible by others This private key w...

A methodology where all the configurational and/or infrastructure codes are set up in a separate single repository is known as GitOps. This suits tools like Ansible, Terraform and Kubernetes, where they do require separate files for their configurati...

Straight to the point, there are tons of things to ask in JS, but these are a few of them which can be a quick refresher. Event loop, Single-threaded programming language - Explain, Asynchronous and synchronous, Promises and callbacks, "This" ke...

Peace to you all , Here is the Link to my previous blogs, Where I have posted about Docker, Containers and DevOps.
This is Day 7 of documenting my DevOps journey .
This blog focuses on Dockerfile and its commands/instructions.
Building images through Dockerfile follows layered approach.
This means that every instruction we write is taken as a separate layer and the former layer provides for the latter layer.
We will get more familiar with this layered approach in the coming times.
We will look at each instruction which can be found on a basic Dockerfile.
The FROM instruction is mandatory for creating an image.
It creates the base image for building the following instructions.
There can be multiple FROM in a DockerFile.
We can also provide any name for referencing in the later instructions using ‘AS’ instruction but not mandatory.
FROM nginx AS base-image
Here FROM takes the image nginx , if present locally it will take that, else it will pull it from dockerhub. The 'AS' sets a name for the nginx image as base-image ( it can be anything ).
This helps in storing a default value in a variable or getting the value on build time and could be used in FROM and many instructions.
ARG version-arg=latest
FROM nginx:${version-arg}
The ARG passes latest as value to version-arg variable and it is used in FROM instruction by calling the name of the variable.
Sets the working directory for the subsequent instructions to come.
This can be used for many reasons where we need some instruction to happen in a different folder and some instruction in a different folder.
WORKDIR path
This is to say that docker container listens on the specified port.
Also , we can mention the protocol prefixed with a slash.
EXPOSE 80
EXPOSE 443/tcp
This executes any command followed by 'RUN', commits it to the current image and that image is used for the following instructions.
We can also pass parameters for running the ‘RUN’ instruction.
RUN <command>
RUN ["exec","param1","param2"]
Copies files from the host to the filesystem of the container.
COPY . /usr/share/nginx/html
The '.' represents the current folder of the host . So the current folder is copied to the respective folder mentioned on the container.
These are very few instructions on docker , but these are predominantly used for creating images and in many cases it is sufficient. We will try to cover the rest in the upcoming blogs.
We learnt about, what are the basic instructions of docker and how some instructions are written to the Dockerfile.
Okay . So hold on, stay with me as we get to know docker more and DevOps even more.
Okay Then , Will get back Tomorrow with more!
Peace be upon you!