DEV Community

Cover image for Learn Docker From Scratch
Desmond
Desmond

Posted on

Learn Docker From Scratch

The problem

Imagine being approached by a friend who has an idea for a startup and you need to launch your app as quickly as possible. You've successfully completed the web app and you're ready to deploy the app but you then realize that your app is running different versions of a technology which would result in version conflicts when deployed .🤔 Now what would you do? "Duuh🤷‍♀️ deploy on several Virtual Machines". Well, possible but then what if we want to perform updates, load balancing? You don't want to be handling hosting environments, runtimes, libraries and OS needed by your application.That would be a lot of work. Enter containers !!

Containers help us deploy our apps easily. Deploying is a simple as running a new container. You can even route users to containers, and trash old ones…If you want less work you can even automate those with orchestrators..

Docker and Virtual Machines | Desmond Nyamador - Dev.to

How do containers work?

Unlike virtual machines which provide hardware virtualization, a container provides OS level virtualization by isolating the software from it's environment and ensuring that it works uniformly despite differences. They make applications easier to work with.

Docker is an example of container based technology.

Let's Get Started!!
To get started with docker head over to Docker and download docker desktop for your OS (Mac, Linux or Windows)

WINDOWS
Before you install docker on windows you have to:
1. Enable Hyper-v
2. Enable hardware vitualization

Linux
Various packages exists depending on your flavour of linux. You can find post installation steps here Docker for linux

MAC
Docker Desktop need MacOs Sierra 10.12 or above.

Run a Container

NB: All commands are the same and do not differ when using a different os
After successfully installing docker desktop, run the following code in you terminal

docker run hello-world

Docker Hello World

That’s it: your first container. The hello-world container output tells you a bit about what just happened. Essentially, the Docker engine running in your terminal tried to find an image named hello-world. Since you just got started there are no images stored locally (Unable to find image...) so Docker engine goes to its default Docker registry, which is Docker Store, to look for an image named “hello-world”. It finds the image there, pulls it down, and then runs it in a container. And hello-world’s only function is to output the text you see in your terminal, after which the container exits.

In the next post we'll take a look at Images.

Top comments (4)

Collapse
 
vonheikemen profile image
Info Comment hidden by post author - thread only accessible via permalink
Heiker

You really missed an oportunity here. Docker actually lets you create an image from scratch.

Collapse
 
nyamador profile image
Desmond

Thanks Heiker would work on that

Collapse
 
vonheikemen profile image
Heiker

don't worry, it was just a joke. You know, the dockerfile sintax FROM scratch and the title learn docker from scratch.

Thread Thread
 
nyamador profile image
Desmond

Oh yeah 😂..I just understood.
Smart!!

Some comments have been hidden by the post's author - find out more