DEV Community

RyanArmani
RyanArmani

Posted on • Updated on

Introduction with Docker

Docker Introduction

Docker is an extraordinarily popular open source containerization platform among developers. Docker enables developers to develop, ship, and run applications through its implementation of containers. Containers are a piece of software that packages up any code and its dependencies, enabling applications to run on various computing environments regardless of differences between system requirements from one computer to another. This popular method of running and delivering apps opens a world of possibilities, with a common use being businesses rolling out updates to existing software, and reverting back to older stages of a software if any errors arise.

Starting with Docker

Docker utilizes a special file called a Dockerfile. a Dockerfile is a file that automatically runs a set amount of code within an application to assemble an image (an image is a set of code that creates a container within docker). One such example of a Dockerfile is included below, which is used to run the NewsAPI app from our class' project.
Image descriptionAn example of a fully functional application, the NewsAPI, is included below as well to demonstrate the full capabilities of docker. This includes a series of links to news articles
Image description One can utilize a query to find specific key terms
Image description

Create a docker file

To create a docker file for your own web app, you will need to clone a copy of your git repository (repo). One way to acquire the link to your repo is by navigating to your repo on github.com. Using my own repo as an example, navigate to the Code tab
Image description, and select the https icon.
Image descriptionYou will see a link to your repo. Copy this link, as we will be utilizing it in the docker environment. Navigate to "play with docker" (https://www.docker.com/play-with-docker), and scroll down until you find the "Lab Environment" tab.
Image descriptionSelect "Get Started, and sign into Docker if prompted. Once signed in, select the "Start" button. You are now ready to set up your web app!

Inside the docker playground, on the left hand side of the screen, click the "+ Add New Instance" option.
Image descriptionIn a moment, you should see a terminal-like sandbox environment appear in docker playground. We can input commands here! For our purposes, we will clone our git repo. Use the command git clone <your-repo-link-here>. For my web app, I used the command git clone https://github.com/IST402GroupB/ip-project.git.
Image descriptionWe will now create a temporary file within our web app. Type in the command touch dockerfile. This command creates an image of a file within docker named dockerfile, which is a file that can be edited within the Docker Editor provided, and can be viewed by the ls -la command.
Image description

Top comments (0)