Introduction to Docker - Part 1

Introduction to Docker - Part 1

Written by Bobby Iliev on Apr 11th, 2020 Views Report Post

Introduction

It is more likely than not that Docker and containers are going to be part of your IT career in one way or another.

In this blog post series I'll cover the following:

  • What are Docker images, containers and Docker Hub
  • Installing Docker on Ubuntu Linux on a DigitalOcean Droplet
  • Working with Docker containers
  • Working with Docker images
  • Deploying a Dockerized app

I'll be using DigitalOcean for all of the demos, so I would strongly encourage you to create a DigitalOcean account follow along. You would learn more by doing!

To make things even better you can use my referral link to get a free $100 credit that you could use to deploy your virtual machines and test the guide yourself on a few DigitalOcean servers:

DigitalOcean $100 Free Credit

Once you have your account here's how to deploy your first Droplet/server:

https://www.digitalocean.com/docs/droplets/how-to/create/

I'll be using Ubuntu 18.04 so I would recommend that you stick to the same so you could follow along.


What is a container?

According to the official definition from the docker.com website, a container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries, and settings.

Container images become containers at runtime and in the case of Docker containers - images become containers when they run on Docker Engine. Available for both Linux and Windows-based applications, containerized software will always run the same, regardless of the infrastructure. Containers isolate software from its environment and ensure that it works uniformly despite differences for instance between development and staging.


What is a Docker image?

A Docker Image is just a template used to build a running Docker Container, similar to the ISO files and Virtual Machines. The containers are essentially the running instance of an image. Images are used to share a containerized applications. Collections of images are stored in registries like DockerHub or private registries.


What is Docker Hub?

DockerHhub is the default Docker image registry where we can store our Docker images.

Here's a link to the Docker Hub:

https://hub.docker.com

You can sign up for a free account.


Installing Docker

Nowadays you can run Docker on Windows, Mac and of course Linux. I will only be going through the Docker installation for Linux as this is my OS of choice.

I'll deploy an Ubuntu 18.04 VM on DigitalOcean so feel free to go ahead and do the same. Once your VM is up and running, SSH to the droplet and follow along! If you are not sure how to SSH, you can follow the steps here:

https://www.digitalocean.com/docs/droplets/how-to/connect-with-ssh/

The installation is really straight forward, you could just run the following command, it should work on all major Linux distros:

wget -qO- https://get.docker.com | sh

It would do everything that's needed to install Docker on your Linux machine.

After that setup Docker so that you could run it as a non-root user with the following command:

sudo usermod -aG docker ${USER}

To test Docker run the following:

docker version

To get some more information about your Docker Engine, you can run the following command:

docker info

With the docker info command, we can see how many running containers that we've got and some server information.

The output that you would get from the docker version command should look something like this:

In case you would like to install Docker on your Windows PC or on your Mac, you could visit the official Docker documentation here:

https://docs.docker.com/docker-for-windows/install/

And:

https://docs.docker.com/docker-for-mac/install/


Conclusion

That is pretty much it! Now you have Docker running on your machine!

We are ready to move to Part 2 of the Introduction to Docker blog post series:

Introduction to Docker Part 2

Let me know if you have any questions!

Bobby

Comments (0)