DEV Community

Alex Ortiz
Alex Ortiz

Posted on • Updated on

docker learn #01: My Learning Journey with Docker Begins!

I've started learning Docker.

For context, I'm the Lead of Developer Sales and Success at Educative.io, a software development learning platform for developers and computer science professionals to learn new skills. Our customers love our platform because they can buy high-quality, self-paced courses in the specific programming language, development framework, or topic they need. These courses equip them with new skills, new knowledge, and the confidence to advance in their craft or prepare for new opportunities.

Part of my job is to find software developers and engineers with subject-matter expertise in specific areas. These Authors then create interactive online learning courses to sell on our platform. The courses are text-only (no video) and often contain quizzes, executable code snippets, and interactive challenges that help learners learn. Even though our free tools for writing these courses are pretty sweet, not every language, framework, or library works out-of-the-box. In some cases, the content creator can leverage our Docker functionality to containerize the app or the learning environment their students will need to interact with.

When this happens, I put on my other hat: supporting Authors as they build their courses, acting as a go-between from the external content creator to our internal dev team to answer questions and remove blockers. This can include things like creating custom Dockerfiles, troubleshooting image builds, or customizing docker jobs to work with our teaching tools.

But I don't know Docker. So I've started learning!

In this series, I'll share what I learn as well as the learning journey itself.

On Learning Openly

I'm a big fan of learning openly, of open-sourcing your learning journeys, as they say. It is very satisfying to learn something new and hard and share the learning path with others as you go. You might get some things wrong along the way, of course, but that's part of what learning is: coming to understand a skill or a subject through an ongoing dialogue of hits and misses, successes and failures, roadblocks and open roads.

One upside of this approach is that two things become a resource to others:

  1. your learnings
  2. the learning journey itself

It's the what and the how, packaged together. Whoever follows or joins you along the way can utilize the grooves you've already set.

Note: Take everything I'll share in this series with a learner's grain of salt. Definitely do your own reading (DYOR), and, when in doubt, check out Docker's very excellent documentation.

By the way, this won't be a comprehensive or how-to series per se. It'll be a collection of learning snapshots. So I invite readers of this docker learn series to fill in their own gaps with Youtube videos, books, online courses, Docker's technical documentation, and hands-on exercises. I'll share some of these resources in my posts.

Here we go.

What I've Learned So Far: The Basics and Some Simple Commands

Writing summaries off the top of your head is a great way to review what you're learning. This improves memory consolidation and future recall, and it boosts your confidence.

So here's a simple summary.

Basic Knowledge

Some of the Docker basics I've learned so far include these:

  • the purpose of a Dockerfile
  • what a docker container is
  • how a docker daemon pulls a docker image from the image registry in order to launch a particular container (i.e., an instance of that image)

A Dockerfile is a list of instructions. These instructions are fed from a client to a docker daemon running on a docker host machine (server). The docker daemon consumes the instructions and builds a docker image. The docker image is stored in a registry and downloaded to the host machine the first time you build a container from that image. The docker container includes the specific application, task, or other process you defined in the Dockerfile. When you run a container, you're running a temporary, short-lived instance of that application, task, or process.

A Few Important Basic Commands

Here are some important commands I've learned about:

  • docker build -> takes a Dockerfile as input and builds a docker image out of it

  • docker pull xyz -> downloads a specific docker image, which you specify, to your docker host machine, but does not launch a container for that image

  • docker run xyz -> launches (runs) a container from the image you specify. So, for instance, docker run node will run a NodeJS instance

  • docker ps -> prints a list of containers you're currently running, along with metadata about each, e.g. name, ID, how long each container has been running, and so on

  • docker stop xyz -> stops a running container (kinda like force quitting an app, but here it's a containerized instance of that app)

  • docker start xyz -> starts a container you've previously stopped

  • docker ps -a -> prints a list of all containers, both the ones running and any you've stopped but haven't yet removed

  • docker rm xyz -> removes a container you specify (containers run on, and are thus removed from, your docker host)

  • docker rmi xyz -> deletes an image (as opposed to a container). Note that this removes the image from your docker host machine, but it does not remove it from the docker registry, naturally

There are a lot more commands and many options (flags) for each command, but this is about what I understand at the moment.

Bonus: MAINTAINER vs LABEL

I learned this week that the docker instruction MAINTAINER has been deprecated in favor of a LABEL instruction. The latter is more flexible and allows the docker image author’s name to be printed alongside other object metadata when running the docker inspect command. So as a best practice, you should use the new approach.

Sample Dockerfile Code - The OLD Way

FROM base_image_name
MAINTAINER image_author_email_address
RUN command_to_run

Sample Dockerfile - The NEW Way

FROM base_image_name
LABEL maintainer="image_author_email_address"
RUN command_to_run

Some Helpful Resources

I'm working through a book and a bunch of videos. Here are just a few:

So there you have it. Independent learning is awesome and really fun. Sharing it is a blast as well.

Thanks for reading docker learn, and see you next time!


docker plugs

For a more extensive treatment of docker from my Educative team and our Authors, check out these other resources:

Also hit that DEV.to Follow button, follow me on Twitter @alexoeducative, and check out our courses at Educative.io. If there's a topic you know well or you'd like to build a course, leave a comment—let's chat :).

Top comments (0)