<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kishor Aswar on Medium]]></title>
        <description><![CDATA[Stories by Kishor Aswar on Medium]]></description>
        <link>https://medium.com/@kishoraswar?source=rss-ff11c6fe2eb1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Kishor Aswar on Medium</title>
            <link>https://medium.com/@kishoraswar?source=rss-ff11c6fe2eb1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 07:21:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kishoraswar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Docker Tutorial For Beginner]]></title>
            <link>https://medium.com/@kishoraswar/docker-tutorial-for-beginner-c5eb79379968?source=rss-ff11c6fe2eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5eb79379968</guid>
            <category><![CDATA[docker-for-beginner]]></category>
            <category><![CDATA[dockerfiles]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Kishor Aswar]]></dc:creator>
            <pubDate>Tue, 22 Feb 2022 19:59:40 GMT</pubDate>
            <atom:updated>2022-02-22T19:59:40.245Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>What is docker?</em></strong></p><p>Docker is a software platform that allows you to build, test, and deploy applications quickly.</p><p>Docker uses OS level virtualization.</p><p><strong><em>Docker Installation on Amazon Linux EC2 Instance:</em></strong></p><ol><li>Launch an instance with the Amazon Linux 2 or Amazon Linux AMI.</li><li>Connect to your instance: $ ssh -i &lt;.pem file&gt; ec2-user@18.220.238.236</li><li>Update the installed packages and package cache on your instance. Command: <strong>sudo yum update -y</strong></li><li>Install docker engine on Amazon Linux host.</li></ol><p>Command: <strong>sudo yum install docker</strong></p><p>5.Start the docker service and check status using below command.</p><p><strong>sudo service docker start</strong> or <strong>systemctl start docker // systemctl status docker</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7eS9rM0T9MYatAIlhVsc-Q.png" /><figcaption>Docker Daemon Status</figcaption></figure><p>6. Check Docker Version using below command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*Iu4IMQvWfJGKWH4THxmvAQ.png" /><figcaption>Docker Version Command</figcaption></figure><p>############################################</p><h3><strong><em>How to pull image and create container:</em></strong></h3><p>Pull image using command <strong>#docker pull &lt;image-name&gt;:&lt;tag&gt;</strong></p><p>Note: By default tag is latest..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*eb14m2Q4U_O0-g2Wwx907Q.png" /><figcaption>#docker pull nginx</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*krqI8k8YhJY7YRvkkokdBQ.png" /><figcaption>docker run -itd nginx</figcaption></figure><p>Using command <strong>#docker run -itd &lt;image-name&gt;</strong>we have created nginx container .</p><p>To access nginx application we have first find IP address of container using command #docker inspect &lt;container-id&gt;</p><p>Once we get container id we can access application locally using curl command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*Ck51GOSuCkOgLNgwu2NDbw.png" /><figcaption>Access Nginx Application Locally on Linux Host</figcaption></figure><p>To access application outside use -p &lt;host-port&gt;:&lt;container:port&gt; option while creating container .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ha54g1rQnJfHnmgqSarK6A.png" /></figure><p>Now we can access nginx on browser.</p><p>http://&lt;public-ip&gt;:80</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*hHo9VWSXmYIMfsJdnOGC4g.png" /></figure><p><strong><em>Docker Basic Commands:</em></strong></p><p>We can find below command using #docker — help command.</p><p>1.attach -Attach local standard input, output, and error streams to a running container</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*h9_Diou1GadstF3KptRSBA.png" /></figure><p>2. build - Build an image from a Dockerfile</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*-vjHuIz4SDPij4_6_hNWJw.png" /></figure><p>3.commit - Create a new image from a container’s changes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*w-UKbUM39ak5OSeAb7DzMQ.png" /></figure><p>4. cp -Copy files/folders between a container and the local filesystem</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*JWMaOMPmvdTMdKYZiaKe3g.png" /></figure><p>5. exec -Run a command in a running container</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*BV5LYUO1ImrBjDPyHIZbFA.png" /></figure><p>6. export - Export a container’s filesystem as a tar archive</p><p>7. import -Import the contents from a tarball to create a filesystem image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*DXuihcq2on15UVOzzDeOlA.png" /></figure><p>8. history — Show the history of an image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cswkE56dkk4xN2pTxLuL-w.png" /></figure><p>9. images — List images</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*N4vyOXhgycx42bCgzJCJpA.png" /></figure><p>10. inspect - Return low-level information on Docker objects</p><p><strong>#docker inspect &lt;container-id&gt;</strong></p><p>11. kill — Kill one or more running containers</p><p><strong>#docker kill &lt;container-id&gt;</strong></p><p>12. login - Log in to a Docker registry</p><p><strong>#docker login</strong></p><p>13. logout - Log out from a Docker registry</p><p><strong>#docker logout</strong></p><p>14. logs - Fetch the logs of a container</p><p><strong>#docker logs &lt;container-id&gt;</strong></p><p>15. pause - Pause all processes within one or more containers</p><p><strong>#docker pause &lt;container-id&gt;</strong></p><p>16. port -List port mappings or a specific mapping for the container</p><p><strong>#docker port &lt;container-id&gt;</strong></p><p>17. ps — List containers</p><p><strong>#docker ps</strong></p><p>18. pull -Pull an image or a repository from a registry</p><p>#docker pull &lt;image-name&gt;</p><p>19. push - Push an image or a repository to a registry</p><p>#docker image push kishoraswar/mynewimage:v1.0</p><p>20. restart - Restart one or more containers</p><p>#docker restart &lt;container-id&gt;</p><p>21. rm -Remove one or more containers</p><p>#docker rm &lt;container-id&gt;</p><p>22. rmi -Remove one or more images</p><p>#docker rmi &lt;image-name&gt;</p><p>23. run -Run a command in a new container</p><p>#docker run -itd &lt;image-name&gt;</p><p>24. start -Start one or more stopped containers</p><p>#docker start &lt;container-id&gt;</p><p>25. stats -Display a live stream of container(s) resource usage statistics</p><p>#docker stats &lt;container-id&gt;</p><p>26. stop -Stop one or more running containers</p><p>#docker stop &lt;container-id&gt;</p><p>27. top -Display the running processes of a container</p><p>#docker top &lt;container-id&gt;</p><p>28. unpause - Unpause all processes within one or more containers</p><p>#docker unpause &lt;contianer-id&gt;</p><p><strong><em>What is image in docker?</em></strong></p><p>Docker image is a blueprint of container or set of instruction to build container.</p><p>Its read only template that contain set of instructions for creating a container that can run on the Docker platform</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Qa_twteJIedWS4nOW4rmlQ.png" /></figure><p><strong><em>In above diagram we can see base image is CentOS using base image we have created final image.</em></strong></p><p>While creating image temporary container is created in background. Inside that container given instruction got executed i.e #yum update and #yum install vim commands.</p><p><strong><em>Dockerfile :</em></strong></p><p>A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image</p><p>Docker can build images automatically by reading the instructions from a Dockerfile.</p><p>Dockerfile contain Instruction part and command part as below</p><p><strong>INSTRUCTION →Command/Arguments</strong></p><p>— — — — — — — — — — — — — — —</p><p>FROM &lt;image-name&gt;</p><p>MAINTAINER &lt;author&gt;</p><p>RUN &lt;OS-CMD&gt;</p><p>CMD &lt;Default First command &gt; [executable, arg1, arg2 ]</p><p>ENTRYPOINT &lt;Default First command &gt; [executable, arg1, arg2 /bin/bash]</p><p>ENV &lt;variable name&gt;&lt;value&gt;</p><p>ARG &lt;variable name&gt; &lt;value&gt;</p><p>USER &lt;user-name&gt;</p><p>WORKDIR &lt;path&gt;</p><p>COPY &lt;hostsrc&gt; &lt;container dest&gt;</p><p>ADD &lt;hostsrc/URL&gt;&lt;container dest&gt;</p><p>EXPOSE &lt;port&gt;</p><p><strong><em>Dockerfile Command Detail With Example</em></strong></p><p><strong>FROM </strong>→ It use for base image.</p><p>ex: FROM ubuntu:latest</p><p><strong>MAINTAINER </strong>→Author of docker file for maintenance</p><p>ex: MAINTAINER Kishor Aswar</p><p><strong>ARG<em> →</em></strong>built-time arguments, not available in containers</p><p>ex: ARG var_name=def_value # default ARG</p><p><strong>ENV </strong>→ environment variables , available in containers</p><p>ex: ENV JAVA_HOME /opt/java Here we setup JAVA_HOME environment variable and value is /opt/java</p><p><strong>ARG Vs ENV</strong><em>: The difference between ARG and ENV is that after you set an environment variable using ARG, you will not be able to access that later on when you try to run the Docker Container.</em></p><p><strong>RUN </strong>→ It will help us to execute OS level command. Its Create new layer in image.</p><p>ex: RUN yum update -y</p><p><strong>CMD </strong>→ Specifies the instruction that is to be executed when a Docker container starts.</p><p>If we have multiple CMD in docker file it will override.</p><p>ex: CMD [“/bin/bash”]</p><p>While creating container if we pass any input it will be override in CMD.</p><p><strong>ENTRYPOINT →</strong>ENTRYPOINT instruction is used to set executables that will always run when the container is initiated. ENTRYPOINT commands cannot be ignored or overridden.If we passing any command after entrypoint it will append on entrypoint command</p><p>ex: ENTRYPOINT [“echo”, “hi kishor” ]</p><p><strong>COPY </strong>→ It will copy file from local system to container.</p><p>ex: COPY myfile /tmp/</p><p><strong>ADD </strong>→ Its similar to COPY but it help us copy multiple files at a time. If we want to copy .tar file from source or remote location we are using ADD instruction in dockerfile.</p><p>ex: ADD myfile.tar /opt/middleware/webapp/</p><p><strong>USER </strong>→ It help us switch user inside container.</p><p>ex: USER root</p><p><strong>WORKDIR </strong>→ It will default working directory inside container.</p><p>ex: WORKDIR /opt/middleware/webapp</p><p><strong>EXPOSE </strong>→ Exposing ports is a way of documenting which ports are used, but does not actually map or open any ports. <strong>Exposing ports is optional</strong>.</p><p>ex: EXPOSE 80</p><p>Sample Dockerfile with all Instruction:</p><p>============================</p><p>FROM ubuntu</p><p>MAINTAINER Kishor Aswar</p><p>USER root</p><p>WORKDIR /opt/myapp</p><p>RUN apt-get update -y</p><p>ENV JAVA_HOME /opt/java</p><p>CMD [“echo”, “Hi Kishor”]</p><p>ENTRYPOINT [“echo”, “hi kishor” /bin/bash]</p><p>EXPOSE 80</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5eb79379968" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>