Coding for Scrubs: What is Docker?

Hi there. Welcome to another series of Coding for Scrubs! We’re going to take a pause on whiteboarding problems and we’re going to talk about a very important tool that developers use! Docker! We’re going to talk about why it’s valuable and how it works. Let’s jump into it!

So, what is Docker?

Let’s imagine you’re a developer. You’re working on a feature for a project you’re working on and everything works fine! You will then send it to the tester, but then the code doesn’t work for them. Why might this be? It’s because the code doesn’t work on the other system due to the difference in computer environments! So, how do we find a solution? There are two approaches to solving our issue. Either using Virtual Machines or Docker. What’s the difference between the two and why do people prefer to use Docker?

Provided by Simplilearn via Youtube

Docker can be perfectly used when there are multiple developers who are working with different frameworks. For example, one developer could be using Ruby on Rails, another using Django, and another using Flask. You may want the applications to be running in different situations. Docker will help run applications with their suitable frameworks.

How does Docker work?

Docker is the base engine installed onto your host machine to build and run containers using Docker components and services. Docker has a client-server relationship. The client is installed on the hardware and the server controls how that Docker client is created. The Docker client and server communicate using REST API. The client is constantly communicating through a command, which is translated using REST API and is sent to the Docker Daemon, or server. The Docker Daemon then checks the client request and interacts with the operating system in order to create or manage these containers.

The Components of Docker:

When you use Docker, you are creating and using images, containers, networks, volumes, plugins, and other objects.

Client and Server:

Docker Client is accessed from the terminal and Docker Host runs the Docker Daemon and registry. A user can build Docker images and run Docker containers by passing commands from the Docker client to Docker server.

Images:

An image is a read-only template with instructions for creating a Docker container. Often, an image is based on another image, with some additional customization. Docker image is built using a file called Docker File. It is then stored in a Docker Hub or in a repository such as registry.hub.Docker.com. This allows other users to have access to the same structure of the Docker environment you’ve created.

Containers:

You will hear that Docker puts your code into a container, a runnable instance of an image. A container is relatively well isolated from other containers and its host machine. You can control how isolated a container’s network, storage, or other underlying subsystems are from other containers or from the host machine. Think of containers as the instructions of what your environment would look like. It makes the environment consistent with multiple developers, testers, and anyone else who is on your team.

Keep in mind, you can run MULTIPLE containers and each of those containers are completely isolated and protected.

Registry:

The registry is an open-source server-side service used for hosting and distributing images. This is how your code can be accessed by multiple users and/or control whether or not you want your repository to be public or private.

Docker does have its own default registry called Docker Hub. In order to build a container, you would use the pull command to get a Docker image from the Docker repository. If you want to store a Docker Image, you use the push command.

Docker pull <image>:<tag>: pulls an image from DTR
Docker push <image>:<tag>: pushes an image from DTR

Conclusion:

Look how useful Docker is! This is definitely a tool that is widely used across companies. Docker really helps increase workflow and build consistent environments throughout the workplace. Thanks for tuning in to another series of Coding for Scrubs! Please check out my previous post if you missed out on last week’s!

Read the Official Docker Docs!

Software Engineer in the making.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store