Blog5

Blog 5

Que Docker?

Before getting knee deep in Dockerfile info, let’s take a moment to go over Docker and the problems it solves. And as always, we begin with Wikipedia’s definition of Docker:

Docker is a set of platform-as-a-service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries, and configuration files; they can communicate with each other through well-defined channels. All containers are run by a single operating-system kernel and are thus more lightweight than virtual machines. — Wikipedia

Alright Docker sounds like some insanely technical tool, and it is. Docker simply is a tool that allows makes making an application, deploying it, and supporting it by using the Docker Container.

Que Dockerfile?

Dockerfiles are used, within Docker, to create images. Those images, made from Dockerfiles, are used to create containers. Within those containers you can deploy, test, and support whatever it is you developed. Pretty cool, if ya ask me.

Before we get anymore technical, I want to explain this one thing. That thing, is that within the Dockerfile, you’re basically laying out a series of commands that will tell Docker what services are to be installed in the image, and how they’re configured. It took me so long to understand this concept, mostly out of fear of learning something new.

The Technical Jargen

The Dockerfile wil consist of whatever commands, or “instructions”, that tell Docker what you want. Here are some of the basic ones and what they do.

-FROM Almost all Dockerfiles begin with this. This instuction sets the base image for the Dockerfile.
-RUN This instruction does what it says it does, runs commands.
-CMD This instruction sets a default command that will be executed when you run the Docker image. But you don’t have tospecify a command.
-COPY This copies a folder/directory from your local machine to your Docker image.
-ADD Similar to the COPY instruction, the ADD instruction lets you do the same thing and extract a TAR file from the source, and use a URL instead of a directory.
-WORKDIR This is used to define the directory in which all your instruction are to be done in.
-ENV This allows you to set certain environment variables, tha tcan be access throughout the Dockerfile.

With just these “instructions” you could build a Dockerfile to setup any kind of image you want. Takes a bit of trail and error in seeing what to put inside of these instructions, but it’s definitely a useful skill to learn, since Docker is used heavily throughout the IT world. Thanks for reading!

Written on October 9, 2020