<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sabbir Ahmmed</title>
    <description>The latest articles on DEV Community by Sabbir Ahmmed (@sabbir185).</description>
    <link>https://dev.to/sabbir185</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F635058%2F39c1fe6c-c791-44ea-8e62-6082d4ebc5a1.png</url>
      <title>DEV Community: Sabbir Ahmmed</title>
      <link>https://dev.to/sabbir185</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sabbir185"/>
    <language>en</language>
    <item>
      <title>Docker beginner approach A-Z that you should know! part 2 | End</title>
      <dc:creator>Sabbir Ahmmed</dc:creator>
      <pubDate>Sun, 19 Dec 2021 04:37:02 +0000</pubDate>
      <link>https://dev.to/sabbir185/docker-beginner-approach-a-z-that-you-should-know-part-2-end-3kga</link>
      <guid>https://dev.to/sabbir185/docker-beginner-approach-a-z-that-you-should-know-part-2-end-3kga</guid>
      <description>&lt;p&gt;Previously, I discussed in detail about Docker's theoretical part and installation process. Before starting this coding part, if you don't know about docker, please read part 1 first &lt;a href="https://dev.to/sabbir185/docker-beginner-approach-a-z-that-you-should-know-353j"&gt;click here&lt;/a&gt;. And if you already know about docker's basic knowledge, you're welcome to part 2.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Linux&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I told you that I will teach you basic Linux commands that are needed only for docker. And I hope, it will be very helpful to start not only docker but also to run the Linux operating system. Open your terminal and type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo su
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;sudo&lt;/code&gt; super user do and &lt;code&gt;su&lt;/code&gt; lets you switch user so that you're actually logged in as a root user.&lt;br&gt;
&lt;strong&gt;pwd&lt;/strong&gt; -&amp;gt; Used to find out the path of the current working directory(folder) you’re in.&lt;br&gt;
&lt;strong&gt;cd&lt;/strong&gt; -&amp;gt; To navigate through the Linux files and directories, use the &lt;code&gt;cd&lt;/code&gt; command.&lt;br&gt;
&lt;strong&gt;ls&lt;/strong&gt; -&amp;gt; If you want to see the list of files on your Linux system, use the &lt;code&gt;ls or ls -a&lt;/code&gt; command.&lt;br&gt;
&lt;strong&gt;mkdir&lt;/strong&gt; -&amp;gt; Use the &lt;code&gt;mkdir&lt;/code&gt; command when you need to create a folder or a directory.&lt;br&gt;
&lt;strong&gt;rmdir&lt;/strong&gt; -&amp;gt; Use &lt;code&gt;rmdir&lt;/code&gt; to delete a directory. But &lt;code&gt;rmdir&lt;/code&gt; can only be used to delete an empty directory. To delete a directory containing files, use &lt;code&gt;rm&lt;/code&gt;.&lt;br&gt;
&lt;strong&gt;rm&lt;/strong&gt; -&amp;gt; Use the &lt;code&gt;rm&lt;/code&gt; command to delete files and directories.&lt;br&gt;
&lt;strong&gt;touch&lt;/strong&gt; —&amp;gt; The &lt;code&gt;touch&lt;/code&gt; command is used to create a file.&lt;br&gt;
&lt;strong&gt;cat&lt;/strong&gt; -&amp;gt; we can create and concatenate( join) files.&lt;br&gt;
&lt;strong&gt;vi&lt;/strong&gt; -&amp;gt; text editor, you can modify and save file.&lt;br&gt;
&lt;strong&gt;echo&lt;/strong&gt; —&amp;gt; The &lt;code&gt;echo&lt;/code&gt; command helps us move some data, usually text into a file.&lt;br&gt;
&lt;strong&gt;cp&lt;/strong&gt; — Use the &lt;code&gt;cp&lt;/code&gt; command to copy files through the command line. It takes two arguments: The first is the location of the file to be copied, the second is where to copy.&lt;br&gt;
&lt;strong&gt;mv&lt;/strong&gt; — Use the &lt;code&gt;mv&lt;/code&gt; command to move files through the command line. We can also use the &lt;code&gt;mv&lt;/code&gt; command to rename a file.&lt;br&gt;
&lt;strong&gt;sudo apt-get update&lt;/strong&gt; -&amp;gt; It is good to update your repository each time you try to install a new package.&lt;br&gt;
&lt;strong&gt;sudo apt-get upgrade&lt;/strong&gt; -&amp;gt; You can upgrade the system&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ma9md30k8qxvlc9s5w0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ma9md30k8qxvlc9s5w0.png" alt="Image description" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Docker&lt;/strong&gt; 💥💥💥
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;image to container&lt;/strong&gt; 🇧🇩 &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;First of all, we want to create a container and to create a container we need an OS image. So, we pull an image from the docker hub. Before starting, we need root access, open terminal and run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo su
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start your docker service and run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;service docker start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you can see docker information using &lt;code&gt;docker info&lt;/code&gt;&lt;br&gt;
However, at this time our goal is to create a container. We need an OS image and we want to take the Ubuntu OS image. For that, run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now see that we have no image so we want to pull an image from the docker hub. For that, run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker pull ubuntu
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now see the real magic. It first searches on our local environment. But we have no ubuntu OS image and that's why it pulls from the docker hub and looks at the file size, it is only almost 28 MB! I already said that docker OS images are light in weight. After downloading and extracting, the file size stands around 72 MB! Now again run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This time you found an OS image. Congratulations! 1st step done. You can try to pull centos OS using &lt;code&gt;docker pull centos&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fux2n4l3wnkr3o1oxno2z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fux2n4l3wnkr3o1oxno2z.png" alt="Image description" width="800" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I told you, we have 3 ways to create an image. And one of them is done, pulling images from the docker hub.🔥&lt;/p&gt;

&lt;p&gt;It's time to make a brand new container. Remember that we have ubuntu OS image, so run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -it --name ubuntu_container1 ubuntu /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;wow! it is looking like some weird things😨. Okay, let me explain. Here &lt;code&gt;run&lt;/code&gt; is a combination of create and start. On the other hand, &lt;code&gt;-it&lt;/code&gt; means interactive mode with a terminal. Then if we want to give a name for a container, we have to use &lt;code&gt;--name&lt;/code&gt; command then the container's name. In our case, container name is &lt;em&gt;ubuntu_container1&lt;/em&gt;. After that, we have selected an image and &lt;code&gt;/bin/bash&lt;/code&gt; always fixed here. So, &lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker run -it --name container_name image_name /bin/bash&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, you're in your container. Run &lt;code&gt;ls&lt;/code&gt; on your terminal. You will see Linux directories. And it is now your development environment as like your personal computer. You can create and run your application in the container.&lt;/p&gt;

&lt;p&gt;Else, you maybe noticed that we get a container ID besides of root@ on the terminal.&lt;/p&gt;

&lt;p&gt;Now, create a file in your container by using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch container1.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to see this file run &lt;code&gt;ls&lt;/code&gt; command. You see! You've created a file in your container. Not only files but also any applications that you want to create and share with others, you can!&lt;/p&gt;

&lt;p&gt;To exit or stop your current container, use &lt;code&gt;exit&lt;/code&gt; command.&lt;br&gt;
And to see your all containers, run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker ps -a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You see all containers here but at this time we can see only one container and which is our ubuntu_container1. Carefully observe, here we found container ID, IMAGE (we used ubuntu, remember?), NAME etc. But if we want to see just running container, we just run &lt;code&gt;docker ps&lt;/code&gt; At this time, we have no running container. Because we &lt;code&gt;exit&lt;/code&gt; our container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5asfkvzpibawlzt50va2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5asfkvzpibawlzt50va2.png" alt="Image description" width="800" height="357"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;container to image&lt;/strong&gt; 🇧🇩 &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We have a container (ubuntu_container1), now we want to convert container into image. So that we can share our files or projects with others. Remember? in our container we created a file (container1.txt). And now we want to share it through an image. So run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker commit ubuntu_container1 my_image1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;ubuntu_container1&lt;/code&gt; is our container name that we want to convert into an image and  &lt;code&gt;my_image1&lt;/code&gt; will be our new image name.&lt;/p&gt;

&lt;p&gt;To see our new image, run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And boom 💥, do you see? In the image list, you see our &lt;code&gt;my_image1&lt;/code&gt; image file. Now you can create a container by using this image and you will find container1.txt file by running &lt;code&gt;ls&lt;/code&gt; command that we created.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flc5fixgzsvlaw4ktqfci.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flc5fixgzsvlaw4ktqfci.png" alt="Image description" width="800" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Again, to create a container by using this image, run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -it --name ubuntu_container2 my_image1 /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now run &lt;code&gt;ls&lt;/code&gt; you will find our container1.txt file 🤩.&lt;/p&gt;

&lt;p&gt;Exit or stop your container by using &lt;code&gt;exit&lt;/code&gt; command and run &lt;code&gt;docker ps -a&lt;/code&gt; this time, you will find 2 containers, &lt;code&gt;ubuntu_container2&lt;/code&gt; is the recent one. And one was created by &lt;code&gt;ubuntu&lt;/code&gt; image and the other was created by &lt;code&gt;my_image1&lt;/code&gt; image. Make sense?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good to know&lt;/strong&gt;&lt;br&gt;
To enter an existing container, run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker attach container_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To delete a container&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker rm container_name/id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To delete an image&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker rmi image_id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To start an existing container but doesn't enter into the container&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker start container_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To start an existing container&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker stop container_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;upload image into docker hub&lt;/strong&gt; 🇧🇩 &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To share your docker image with others, you have to upload your image into the docker hub. For that, first you have to create an account on &lt;code&gt;hub.docker.com&lt;/code&gt;. Simple sign-up process! After successfully sign-up, back your terminal and run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then enter your &lt;code&gt;username&lt;/code&gt; and &lt;code&gt;password&lt;/code&gt; and if all is okay, it will show you &lt;code&gt;Login Succeeded&lt;/code&gt;. And now you're ready to upload your image into the docker hub.&lt;/p&gt;

&lt;p&gt;We need to tag our image. That mean's, we have to set a name that we want to store in our docker repository. so run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker tag my_image1 sabbir185/my_image1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;after &lt;code&gt;tag&lt;/code&gt;, our container image name and then a name that we want to set to store our container image. For example, I set a tag name &lt;code&gt;sabbir185/my_image1&lt;/code&gt; for our container image &lt;code&gt;my_image1&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Now run the &lt;code&gt;push&lt;/code&gt; command to upload the image. After &lt;code&gt;push&lt;/code&gt; command, needs tagged image name. And my case &lt;code&gt;sabbir185/my_image1&lt;/code&gt;. Now hit enter&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker push sabbir185/my_image1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Refresh your docker hub profile, you will see an image. 🥳😎&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjks3lpsrzevu91y1gb8r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjks3lpsrzevu91y1gb8r.png" alt="Image description" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, you can pull your docker image or share it with others. For example in my case, my docker image &lt;code&gt;sabbir185/my_image1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If I want to pull my docker image, I just run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker pull sabbir185/my_image1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember? I have already discussed it 🤩🥰.&lt;br&gt;
.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Dockerfile to image&lt;/strong&gt; 🇧🇩 &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I told you, there are 3 ways to get an image. This is another method to gain a docker image and not only a popular one but also easy one of them. To create an image, first we have to create a Dockerfile, so run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch Dockerfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, open and write what you want to build. For my case, I want to create a ubuntu image and in image file, want to create a file name test1.txt. You have to open Dockerfile by&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vi Dockerfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And press &lt;code&gt;i&lt;/code&gt; for write into the text editor.&lt;br&gt;
&lt;code&gt;FROM ubuntu&lt;/code&gt;&lt;br&gt;
&lt;code&gt;RUN echo "Welcome to docker" &amp;gt; /tmp/test1.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;press &lt;code&gt;Esc&lt;/code&gt; key and &lt;code&gt;:wq&lt;/code&gt; then enter. Now run to build image&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t image2 .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can set any image name instead of image2&lt;/p&gt;

&lt;p&gt;Check image&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Bonus talk&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
There are some other topics. For example docker volume, port/expose, docker-compose etc. But For a beginner, I think it's enough for you now. Practice it and then explore some advanced topics that you want.&lt;br&gt;
.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;Thanks for your time&lt;/code&gt;🥰
&lt;/h3&gt;

</description>
    </item>
    <item>
      <title>Docker beginner approach A-Z that you should know! part 1</title>
      <dc:creator>Sabbir Ahmmed</dc:creator>
      <pubDate>Thu, 16 Dec 2021 06:56:38 +0000</pubDate>
      <link>https://dev.to/sabbir185/docker-beginner-approach-a-z-that-you-should-know-353j</link>
      <guid>https://dev.to/sabbir185/docker-beginner-approach-a-z-that-you-should-know-353j</guid>
      <description>&lt;p&gt;Docker is one of the hottest topics in the software technology industry. It was first introduced in March 2013 and developed by Kamel Founadi, Solomon Hykes, and Sebastien Pahl. Docker is written by &lt;code&gt;Go programming language&lt;/code&gt;. Here, I will try my best to introduce docker's main concepts to you very easily. First of all, you have to know about Linux. If you already know about Linux's basic commands so you're welcome. We can install docker on any OS but docker-engine runs natively on Linux distribution.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;But don't worry I will teach you Linux's basic commands.🤩&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;So, what is docker?&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;Docker is an open-source centralized platform designed to create, deploy and run applications. Docker is a set of platform as a service ( PaaS ) that uses OS level virtualization.&lt;/code&gt; &lt;em&gt;Do you understand?&lt;/em&gt; 😄&lt;/p&gt;

&lt;p&gt;Okay have a look, by using docker we can share our applications or projects very easily with others. Sometimes our development environment and other people or team's environments are different. So that, they can't run your project as you can from your local environment. Because maybe other environments have missed some dependencies that are required to run your application. This is a very panicked situation. And to resolve this situation Docker has come. Docker builds a container with necessary dependencies. Each container treats as our local machine.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Docker's concept&lt;/strong&gt;&lt;br&gt;
Docker's main concept comes from Virtual Machine. Docker is a tool that performs OS ( operating System ) level virtualization, also known as containerization. And every docker's VM is called a &lt;strong&gt;container&lt;/strong&gt;. Docker's concept is different from actual VM ( virtual machine ). VM uses hardware-level virtualization. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;OS level virtualization&lt;/code&gt;: A virtual machine concept that uses mainly operating systems. It has no direct relation to the host ( hardware resources for example RAM, processor, hard disk, etc ). When it's needed, that time only uses host resources. It does not block host resources. It's no need for brand new operating system installation panic because it adopts the main OS as needed. That's why Docker container is very &lt;strong&gt;lightweight&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;hardware-level virtualization&lt;/code&gt;: Virtual Machine ( like VMware ) blocks defined host resources that's why we can able to create &lt;strong&gt;a limited number&lt;/strong&gt; of VM on our machine. It has a direct relationship with host resources. Else, every VM needs to install individual a brand new OS and other necessary applications to run our projects or applications. It is a very time-consuming task. For these panic reasons, docker has come into the picture.🥳💥 &lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Components of docker:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;Docker container&lt;/code&gt;: A container is just like a Virtual Machine. it holds the entire packages that are needed to run the application. A container also holds OS but this OS is very lightweight. Some people say that container has no OS but practically container holds OS. It adopts necessary files from the docker daemon and base OS. First of all, the docker daemon search files locally but if not found, it pulls files from the docker hub.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Docker engine&lt;/code&gt;: Docker engine is called the docker daemon. Docker daemon runs on the host OS. It is responsible for running docker containers and managing docker services. Docker daemon holds all images to create a container.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker image&lt;/code&gt;:  Docker images are the read-only binary templates used to create docker containers. An image holds all packages. To create a container, an image is needed. We can get an image in 3 ways:-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;By taking an image from the docker hub.&lt;/li&gt;
&lt;li&gt;By creating an image from Dockerfile.&lt;/li&gt;
&lt;li&gt;By creating an image from exiting docker container.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;Docker client&lt;/code&gt;: Docker users can interact with docker daemon through a client. Docker client uses CLI (Command line interface) and Rest API (Application Programming Interface) to communicate with docker daemon. When a user runs any command on the docker client terminal, the docker client terminal sends it to the docker daemon.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Docker host&lt;/code&gt;: Docker host is used to provide an environment to execute and run applications. It contains the docker daemon, images, containers, networks and storage. Host means our hardware section.&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;strong&gt;So, why should we learn docker?&lt;/strong&gt;&lt;br&gt;
I have already discussed actually docker's necessity. So, in a short form --&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To solve our application's dependencies problem&lt;/li&gt;
&lt;li&gt;It doesn't pre-allocate RAM.&lt;/li&gt;
&lt;li&gt;CI ( continuous Integration ) efficiency.&lt;/li&gt;
&lt;li&gt;less cost ( hardware/resources are used as needed ) &lt;/li&gt;
&lt;li&gt;It is light in weight.&lt;/li&gt;
&lt;li&gt;It can run on physical h/w or virtual machine or even on the cloud.&lt;/li&gt;
&lt;li&gt;You can re-use the image.&lt;/li&gt;
&lt;li&gt;It takes very less time to create a container.&lt;/li&gt;
&lt;li&gt;Easy to create, deploy and run application.&lt;/li&gt;
&lt;li&gt;Docker container holds your all software development packages and after making a docker image, you can share it with everyone🔥 &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Enough talks, let's code&lt;/em&gt;&lt;/strong&gt; 😍&lt;br&gt;
To work with docker we need to install docker in our system. Download or use command lines from this &lt;a href="https://docs.docker.com/engine/install/"&gt;click here to install docker&lt;/a&gt; and follow instructions as said there. Very easy process, doesn't it? 😎&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After successfully install open your terminal or cmd(windows user)
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;It will show a version number. Congratulations!🥳 docker installation has been successfully done.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If it doesn't work, don't worry. You have to turn on docker's service. Open your terminal and type
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;service docker start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;After check status&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;service docker status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you're ready to go into docker's world✌️😁&lt;/p&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;code&gt;Next part 2&lt;/code&gt;&lt;/strong&gt; &lt;a href="https://dev.to/sabbir185/docker-beginner-approach-a-z-that-you-should-know-part-2-end-3kga"&gt;click here&lt;/a&gt;
&lt;/h3&gt;

</description>
    </item>
    <item>
      <title>'this' keyword in JavaScript simple explanation with call(), apply(), bind()</title>
      <dc:creator>Sabbir Ahmmed</dc:creator>
      <pubDate>Sat, 31 Jul 2021 12:22:23 +0000</pubDate>
      <link>https://dev.to/sabbir185/this-keyword-in-javascript-simple-explanation-with-call-apply-bind-3l40</link>
      <guid>https://dev.to/sabbir185/this-keyword-in-javascript-simple-explanation-with-call-apply-bind-3l40</guid>
      <description>&lt;h1&gt;
  
  
  &lt;em&gt;'this'&lt;/em&gt;
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;First write a simple code on your browser console ,&lt;br&gt;
&lt;code&gt;console.log(this);&lt;/code&gt;&lt;br&gt;
wow! You see a window object, right ?! but why?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For discussion, I divided this topic into 4 parts --&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implicit binding&lt;/li&gt;
&lt;li&gt;Explicit binding&lt;/li&gt;
&lt;li&gt;new binding&lt;/li&gt;
&lt;li&gt;window binding&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Implicit binding :
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const student = {
    name: 'Sabbir',
    dept: "CSE",
    namePrint: function(){
        console.log(`My name is ${this.name} Ahmmed`);
    }
}

student.namePrint();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;from above code we can see that, we are printing name from object using ‘this’ keyword. ‘this’ actually reference a nearest object and that’s why here nearest object is student and inner this object namePrint is a property which is a function and print name of student. So, here ‘this’ holds properties of student&lt;/p&gt;

&lt;p&gt;Another,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const student = {
    name: 'Sabbir',
    dept: "CSE",
    namePrint: function(){
        console.log(`My name is ${this.name} Ahmmed`);
    },
    student2: {
        name: 'Jubayer',
        dept: "EEE",
        deptPrint: function(){
            console.log(`Department name is ${this.dept}`);
        }
    }
}

student.namePrint();
student.student2.deptPrint();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;here, student2 is a property of student but student2 itself is an object. So, we know that ‘this’ holds nearest object. That’s why here ‘this.dept’ prints EEE not CSE.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Simple and bonus Tricks :&lt;/code&gt; look at your calling function deptPrint(), this function is calling using dot(.), before dot(.) you see an object ( student2 ) right ? Yes, for deptPrint function ‘this’ holds student2 properties ! nearest properties ! &lt;/p&gt;

&lt;p&gt;So, can you tell me which object actually reference for namePrint()’s ‘this’ ? &lt;code&gt;comment please&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Explicit binding : Call(), apply(), bind()
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;call() :&lt;/code&gt; call method is helper function of this. 'this' keyword by default reference a nearest object. But using call() method we can set that which object we can call for a function. call() can take parameter and 1st is an object and 2nd multiple parameter for function . &lt;br&gt;
For example : functionName.call(objectName, p1, p2, .... );&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var printName = function(v1, v2, v3){
    console.log(`${this.name} is ${v1}, ${v2} &amp;amp; ${v3}`);
}

var sabbir = {
    name: "Sabbir",
    dept: "CSE"
};

var v1 = 'good';
var v2 = 'boy';
var v3 = 'in the class';

printName.call(sabbir, v1, v2, v3);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;apply():&lt;/code&gt; Same as call() but call() can take parameter individually, On the other hand apply() can take array as a parameter. For example : &lt;br&gt;
const p = [p1, p2, p3,...]&lt;br&gt;
functionName.apply(objectName, p );&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var v1 = 'good';
var v2 = 'boy';
var v3 = 'in the class';
const v = [v1, v2, v3]

printName.apply(sabbir, v);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;bind():&lt;/code&gt; Same as call() but doesn't call immediately. It stores values in a variable. After that, we have to call that variable as a function. For example : &lt;br&gt;
const &lt;em&gt;newFunc&lt;/em&gt; = printName.bind(sabbir, v1, v2, v3);&lt;br&gt;
&lt;em&gt;newFunc();&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var printName = function(v1, v2, v3){
    console.log(`${this.name} is ${v1}, ${v2} &amp;amp; ${v3}`);
}

var sabbir = {
    name: "Sabbir",
    dept: "CSE"
};

var v1 = 'good';
var v2 = 'boy';
var v3 = 'in the class';

const newFunc = printName.bind(sabbir, v1, v2, v3);
newFunc();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  new binding :
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Student(name, dept){
    // let this = Object.create(null);

    this.name = name;
    this.dept = dept;
    console.log(`${this.name} is now ${this.dept} student.`);

    // return this
}

const sabbir = new Student('Sabbir', 'CSE');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;'new' keyword creates an object and ‘this’ keyword just reference that object’s properties. So, ‘this’ actually holds new Student’s properties.&lt;/p&gt;

&lt;h4&gt;
  
  
  window binding:
&lt;/h4&gt;

&lt;p&gt;At the beginning , we print ‘this’ keyword that we found a window object. Because, I already told you that ‘this’ actually points to the nearest object, right? so, when ‘this’ does not find any of our custom-defined objects, it points to window object for browser and global object for Nodejs. Because we know that by default every browser has a window object.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Bonus Tricks :&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you confuse about the reference of ‘this’, just do &lt;code&gt;console.log(this)&lt;/code&gt; and find out its object. &lt;/li&gt;
&lt;li&gt;You may use &lt;code&gt;“use strict”&lt;/code&gt; to the beginning of a script or a function.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>JavaScript tricky interview questions</title>
      <dc:creator>Sabbir Ahmmed</dc:creator>
      <pubDate>Fri, 21 May 2021 15:37:29 +0000</pubDate>
      <link>https://dev.to/sabbir185/javascript-tricky-interview-questions-26ho</link>
      <guid>https://dev.to/sabbir185/javascript-tricky-interview-questions-26ho</guid>
      <description>&lt;h2&gt;
  
  
  What are the truthy and falsy values of javascript?
&lt;/h2&gt;

&lt;p&gt;JavaScript falsy means false of boolean condition context. Mainly, six expressions are called falsy. They are false, ‘’(empty string), undefined, null, NaN and 0. And the rest of the expression treats truthy. For example –&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let value = NaN;

if(value) {
    console.log( “Truthy value”);
} else {
    console.log( “Falsy value” );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output: False value, because here boolean condition expression is false.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the difference between null and undefined?
&lt;/h2&gt;

&lt;p&gt;null and undefined both are reserve keywords of javascript. In javascript null is used to assign an empty value, that’s means nothing. On the other hand, if we declare a variable but not define it yet at that time, the variable will show undefined. For example –&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let value;
console.log( value );     // undefined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Else, if we don’t return anything from the function, it will show undefined.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the difference between == and === ?
&lt;/h2&gt;

&lt;p&gt;Double equal ( == ) is used for comparing two variables, but it doesn't check their data types. If one is an integer and another is a string but both contain the same value then it will be true. For example — -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x = 4 ;
let y = “4” ;
if ( x == y ) {
    console.log( “ condition is true “ );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But, three equal not only compare two variables but also check their data types. If data types are the same both, so they are truthy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Define scope and block scope
&lt;/h2&gt;

&lt;p&gt;The scope is just like the area. One is global scope and another is local scope. In general, when we declare a variable following by ES6 rules such as let and const in the function that variable is called function scoped variable or local variable. But if we want to declare a variable outside of a function is called global variable and its access is everywhere. For example –&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const x = 15       // this is global variable or global scope

function doSomething() {
    const y = 15 ;           // local or function scoped variable
    const sum = x + y ;     // the variable which are inside of 
    return sum;            // curly braces are called block scope variable
}

console.log( doSomething() ); // 30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Noted that, you can’t access y and sum variables outside of doSomething() function. The scope of y and sum are only in doSomething().&lt;/p&gt;

&lt;p&gt;let and const are called block scope keywords. You can’t access outside of block &lt;code&gt;curly braces { }&lt;/code&gt;. And var is a keyword that is called function scope variable.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is hoisting?
&lt;/h2&gt;

&lt;p&gt;Hoisting in a JavaScript's default behaviour. In javascript, var is a keyword that is used to declare variables. This var allows hoisting, hoisting means you can access a variable from anywhere in the parent scope. Hoisting set a reference of variable in the global scope or immediate parent scope. But doesn’t carry assigned value. For example –&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const playFootball = () =&amp;gt; {

    console.log("gameName hoisting : ", gameName );     // undefined

    let rain = true;

    var gameName = "Football";

    console.log("status hoisting : ", status );       // undefined

    if( rain ) {
        var status = "continue game" ;
    }

    console.log("status : ", status );               // continue game

}

playFootball();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;NB : const, let and arrow function do not support hoisting&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Closure in JS?
&lt;/h2&gt;

&lt;p&gt;The closure is a hot topic of JS. I’m going to discuss this here briefly. In JavaScript, closures are created when the inner function is created inside of a function. That inner function holds the reference from its parent function scope. For example –&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4fs2cpqjd22b1utqruta.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4fs2cpqjd22b1utqruta.png" alt="Alt Text" width="800" height="303"&gt;&lt;/a&gt;&lt;br&gt;
Here, num2 is used by the inner function that time closure appears. And num1 comes from global scope, global variables are always reserved and any function can use them. But a variable in the function when it is used by an inner function that time closure is created.&lt;/p&gt;

&lt;p&gt;A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). In other words, a closure gives you access to an outer function’s scope from an inner function.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>es6</category>
      <category>interviewquestions</category>
    </item>
  </channel>
</rss>
