The Power Of Docker

reyesedwin

Edwin Reyes Rodriguez

Posted on February 28, 2022

The Power Of Docker

Initially, I had never heard of Docker or even viewed examples of utilizing it. However, I now understand why Docker is so powerful after playing with it a bit.

Today I will cover the effectiveness of Docker, getting started with playing with Docker and how to create a Dockerfile.


What is Docker?

Image of Docker logo
You might be questioning yourself, "what the hell is Docker?" Trust me, I was there too. Docker is an open-source platform that lets developers build, ship, and run applications. Docker is powerful because it makes it easier for you to separate your applications from your infrastructure, enabling rapid software delivery.

How does it work?

Docker works by providing a standard way to run your code. Docker is an operating system for containers. Just as virtual machines virtualize (remove the need for direct management) server hardware, containers virtualize the operating systems on servers. Each server has Docker installed and provides simple commands for building, starting, and stopping containers.

Getting Started

To get started, head over to the Docker 101 tutorial under tutorial. You can either take the tutorial on your desktop or in the cloud. In this example, I would be taking the tutorial in the cloud found here.
Image description of docker

To access their interactive playground, you first need to create an account. If you have an account, simply login in using your Docker ID and password.

Once you log in, you'll see your own Docker VM. To launch Docker's tutorial, you first must create an instance.Image description of docker

Next, in your PWD terminal, write the following command

docker run -dp 80:80 docker/getting-started:pwd
Enter fullscreen mode Exit fullscreen mode

This would create a container in port 80.
Image description of docker

After successfully running the command, port 80 would display a container containing the Dockers 101 tutorial. Throughout this series, you will learn the commands for Docker while seeing the benefit of why building a microservices infrastructure is better instead of a monolithic one.
Image description of docker


Image description of tutorial

Congratulations, you have reached all the necessary steps to start with Docker. Now head on over to the tutorial and learn how to utilize Docker in your applications.


NASA API

In this sections I would be teaching you how to create a Dockerfile for one of my latest project.

To run the NASA API project in Docker, we need to ensure our Docker file has the needed scripts.

  1. In Dockers playground, first, clone our repository and cd into the folder.
    Example of cloning a repo

  2. Next, we need to create a Docker file. In your PWD type touch Dockerfile.
    Image description of docker

  3. After creating the file, you'll want to open the editor's tab and locate the Dockerfile.
    Image description of docker

  4. Our Docker file needs some scripts to run. In the Dockerfile, enter the following command and save the new changes.

FROM node:12

WORKDIR /home/node/app

COPY package.json ./
RUN yarn install

COPY . .

CMD [ "yarn", "start" ]
Enter fullscreen mode Exit fullscreen mode
  1. Next, we need to build the container image using the docker build command. docker build -t nasa-image Image description of pwd

Let's run the application now that we have an image! To do so, we will use the docker run command.

  • docker run -dp 8000:8000 nasa-image

  • After running the command open your local host with the port 8000.

At this point, you should have a running Docker application.

As always, thank you for reading, and I hope you have a wonderful day.

💖 💪 🙅 🚩
reyesedwin
Edwin Reyes Rodriguez

Posted on February 28, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related