DEV Community

Julian Sim
Julian Sim

Posted on

Working with Docker

Introduction

Although it's possible to create web containers without tools like Docker, utilizing Docker makes it a lot easier to build, deploy, and manage containers. To use an analogy, Docker is like the container development toolbox -- it keeps everything nice and tidy for the developer, with all the mainstay tools located conveniently where the developer wants them within a single API.

And with how great it is, it's pretty easy to get started! Just head over to this link to start playing around with Docker!

Creating Docker Files for NASA Image Search

A pretty common use case of Docker would be to access and work with API services. Here, we'll describe how to hook up to the NASA web search API through the lens of NewsAPI services.

First, you'll want to press ADD NEW INSTANCE within the Docker Playground. Then you can clone a git server which contains the relevant API information, and then change your directory over.

Next, we'll want to set up our file structure accordingly.

Run cp dot.env.example dot.env, which should create a dot.env file for you. Your file structure should look something like this:

File structure

Then, go back to the main Docker screen and press the Editor button. Now, we need two pieces of information. First, the API key from NASA. And secondly, the public URL of the microservice. (This can be found by opening port 4000, or the equivalent, and then copying the link.) Once we have that information, we can switch back to the file structure tab and copy that info in.

Next Steps

Having done so, we can run docker-compose up and view our results through both our front-end and back-end ports. Great job!

Back End Work

Feel free to delve into the back-end as well! You can add /graphql to the end of the link when you click your back-end link, and you'll be taken to the GraphQL sandbox where you can do things like run manual queries!

Discussion (0)