DEV Community

Abbey Lyle
Abbey Lyle

Posted on

Intro to Docker

In this blog post, I will be going over what Docker is, how it's useful, and how to get started with it on your own!

What is Docker?

Docker is a platform that delivers software in packages called containers. A container packages up all of the components for an application to run, which allows it to run faster and more safely. Docker containers are the most reliable and fast in the industry!docker

Get Started

To start playing with Docker, I first recommend going through this beginner tutorial to get familiar with how it works. https://training.play-with-docker.com/beginner-linux/

Next, you can start your own Docker instance here. https://labs.play-with-docker.com/. Once you create a new instance, you have access to your very own server running Docker!

Creating Dockerfiles to Communicate with API (NASA Image and NewsAPI)

For some context, we can also look at how Docker is used to create a connection to an API. To start, clone a repository that you'd like to use using a git clone and cd command like I did below.
clone

Next, we need to create a new environment for us to start working in Docker. Run this code cp dot.env.example dot.env in the command line to do so! Now we should have a new file called dot.env. To view it, we can open the editor and see it in the file list.
file menu

Our next step is to get the API key and our endpoint! An API key is almost like a password in order to use the API. Some APIs are offered publicly like the NASA Image API, meaning that we do not need to generate a key for that example. However, the NewsAPI does need a key which could be accessed here.

To get our endpoint, it is a little more complicated. In the docker screen, you can click on "Open Port". We are going to choose to open port 4000. A new window should open with a blank page, don't worry! This is just because we haven't finished setting it up yet! Copy this URL as our endpoint.
open port
port 4000
page

Now that we have our API key (if needed) and our endpoint, we can enter both of these into the editor window for our new file.
editor info

To run up our own site, you can type docker-compose up in the command linerun Clicking 80 because it is the front-end port should show the results from the API! Best of luck!

Top comments (0)