DEV Community

TaylorMorini
TaylorMorini

Posted on

Getting Started with Docker

Why is Docker a Powerful Tool?

One of the main reasons Docker is a powerful tool is its architecture. Docker uses a client-server architecture. According to the Docker documentation,

The Docker client talks to the Docker daemon, which does the heavy lifting of building, running, and distributing your Docker containers

A visualization of this occurring:

Docker Architecture

Starting out with Docker

To begin using the Docker Playground follow these steps:

  • Go to this link

  • Navigate to the section labelled "Play with Docker"

docker starting out

  • Log in or create an account

  • Press the start button and add a new instance

How to Create a Dockerfile for NASA Image Search

Setup

  1. In the Docker Playground add a "New Instance". This will open a terminal on the screen.
  2. On GitHub, navigate to the Nasa Image Search repository and click "Code". Copy the link, and in the Docker Playground run a git clone and cd into the cloned repo

console img

Configure

  • Run this command: touch "Dockerfile". This will create a new file called Dockerfile. This is where custom settings can be added.
  • Access your new file via the "Editor" in Docker Playground.

editor

  • The document that you have added will need to be configured.
    docker

  • Now we must reference an endpoint for Nasa Image Search. For this example, the endpoint would be https://402a.github.io/ip-project/

In the News example, this is where you would run cp dot.env.example dot.env. This would give you the ability to open the dot.env file and populate it with specific data (a generated API Key and the NewsAPI endpoint):

endpoint

For the Nasa Image Search example you can first run another touch command. For this, I ran touch "dot.env". Here, you would populate the document via the editor. The endpoint, https://402a.github.io/ip-project/ is added to this document.

Open Port

  • Once you have completed the configuration, you can now click on the "Open Port" button at the top of the Docker Playground screen.

open port

  • You will be prompted to enter a port number. For this example, I inputted "4000"

4000

  • You will not immediately be able to open the desired page. To do so, you will need to copy the URL of the page that opens when you input "port 4000".

4000-2

  • This URL should be added to the dot.env file as the endpoint. Click 'Save' after this has been added.

Starting the application

  • After everything has been added, run the line docker-compose up in the playground. This will open port 4000.

4000 opens

  • Click on port 80. If all was successful, you will be able to view the working application.

News Example:

port 80

Helpful Links:

  1. Docker Documentation

  2. Nasa Image Search Code

  3. For the News API Key: News API Site

Top comments (0)