What is Docker for?

Rasikahayu
Akhirnya
Published in
5 min readApr 29, 2020

Containers are abstractions at the application layer that package code and dependencies together. Multiple containers can run on the same machine and share the OS kernel with other containers, each running as an isolated process in the user’s space. Containers take up less space than VMs (container images are typically tens of MB in size), can handle more applications and require fewer VMs and operating systems.

Docker is one of container technology. You can use other tools other than Docker but now let me introduce you to Docker. Docker is used when you have many services that work in isolation and function as providers of data to web applications. Docker containers abstract the operating system kernel without emulating hardware, which makes it a lightweight, portable and resource-efficient environment to deploy and manage your apps. Docker runs on any local, hybrid or private cloud, so you can easily migrate your container apps from one infrastructure to another. With Docker you can develop your apps locally and push them to production, or get hold of ready apps at one of public or private image repositories, and they will run in the same way in any cloud.

For example you work in teams and each of you work on one app and each app use different frameworks. It’s gonna be expensive and heavy if each application has to build all frameworks on their machine since they don’t use all of that.

You can see the illustration at the picture below where different applications use different frameworks, different environment, but they will be deployed as one system. So here is the function of Docker, it provides you several environment used by each applications without making the system heavy and expensive to build, to be run, and to be deployed.

Here are some purposes of Docker:

  • It’s a simple and intuitive tool.
  • It enables you to spend less time on configuration and more time on building software.
  • It will allow you to build up independent containers that will interact with each other seamlessly with accuracy and speed.
  • It is a fast and consistent way to accelerate and automate the shipping of software.
  • It saves developers from having to set up and configure multiple development environments each time they test or deploy

Why dont we just use Virtual Machine instead of using Container?

The reason why using containers is better than using vitual machine are:

  • Virtual machine occupies a lot of memory space since there’s Host OS and each Guest OS running for each applications,
  • Virtual machine has long boot-up time if you compare to Docker containers,
  • Running multiple virtual machines leads to unstable performance where containers have a better performance as they are hosted ins a single Docker engine,
  • Virtual machine is difficult to scale up
  • Virtual machine has low efficiency as they literally run different OS each time they run each applications
  • Docker containers is easily portable across different platforms
  • Data volumes in Docker containers can be shared and reused among multiple containers where it cannot be shared in virtual machine.

How to use Docker?

First, setting up your computer by installing Docker on operating system you have in your computer. Once it’s installed, you can test your Docker installation by running this command.

You can try it by use docker run command, for example this command

If you want to look what are containers that are currently running, you can type docker ps. But since you just started your docker now, it’s still empty. You can try it later!

WEB APPS WITH DOCKER

Let’s start by taking baby-steps. The first thing we’re going to look at is how we can run a dead-simple static website. We’re going to pull a Docker image from Docker Hub, run the container and see how easy it is to run a webserver.

In the above command, -d will detach our terminal, -P will publish all exposed ports to random ports and finally --name corresponds to a name we want to give. Now we can see the ports by running the docker port [CONTAINER] command

You can open http://localhost:32769 in your browser.

You can also specify a custom port to which the client will forward connections to the container.

To deploy it in a platform like gitlab, we can use Dockerfile to make it auto build in gitlab environment. Here is the example of what Dockerfile looks like.

How is my docker experience in developing a software?

In my experience in developing software course, we don’t use containers since each application in our web applications is basically use the same framework and environment, that is Django. We use SQLite for database but it still goes well when we build, run, and deploy them. We have no thought yet to use docker containers within our project.

If you wanna read more about containers and docker, go to:

https://www.quora.com/What-is-Docker-When-should-I-use-Docker

--

--

Rasikahayu
Akhirnya
Editor for

In needed for motivation to keep happily living :)