Tools: Part 1: Learning Docker for beginners

Tools: Part 1: Learning Docker for beginners

What is a Dockerfile?

Steps to create a Dockerfile:

Diff. between CMD and RUN instructions: It contains instruction that docker uses to package up an application into an image. Containers and Images, What are these? Simplified Analogy: Think of images as a class(blueprint) and containers as running instance(objects) for that blueprint. By default docker runs an application with the root user that has the highest privileges. Here is a sample Dockerfile for a simple react application. Here is a list of useful commands. Templates let you quickly answer FAQs or store snippets for re-use. as well , this person and/or - Images: An image includes everything an application needs to run. It includes application files, environment variables and so on.

- Container: Once we have an image, we can start a container from it. A container is like a VM in a sense that it provides an isolated environment for executing an application. Similar to VM we can stop and restart a container. - Choose a correct base image- Setup the working directory- Copy application files into the image. Example: COPY <source> <destination>- Exclude files & folders(node_modules, venv, etc)- Adding environment variables- Exposing ports - With both these we can execute instructions. The RUN instruction is a build time instruction. This is executed at the time of building an image. Example: npm install- The CMD instruction is a runtime instruction, it's executed when starting a container.