Docker Guide

Diptendu Biswas
3 min readApr 20, 2021

Docker: Docker is a containerization platform that makes your project portable in the form of a Container (executable package of software)so that the project works seamlessly in any environment. Docker works like Build Image, Ship Image and Run Image.
Docker uses a client-server architecture with Rest API. The server side is the Docker Engine.

Docker logo

Why Docker?
Keeping it simple when a developer develop any project it runs absolutely fine in developer’s machine but as soon as the project is moved to somebody’s computer, the project usually fails to work properly. To solve “It worked on my machine” problem, Docker comes into play. It makes the project sealed in Container(Isolated Environment) and can be moved anywhere and the project will work perfectly as before.

  • With Docker, we get a better CPU utilization
  • With Docker, the boot up time is super less than the traditional OS boot up.
  • With Docker, we get Super less size for our applications
  • Integration with other operations tools.

How it works
After the installation done in your system from https://www.docker.com/get-started . Then create an account on docker hub. Make sure your Docker App is running.

To create new container

Run your first Container by running the following command in CMD or Bash window.
docker run --rm -ti ubuntu bash -c "sleep 2; echo Learn more"
A container will be created which you can find on docker desktop app.
Here,
— rm to remove the container after it finish
-ti is used for terminal index

Docker Image : It is a read-only template that contains a set of instructions for creating a container that can run on the Docker platform.

Image Contains:
- A cut down OS
- A runtime environment (eg, Node)
- Application files
- Third party Libraries
- Environment variables

Make Container from an Image :

$ docker run -ti ubuntu:latest bash

Take a look on running images use :
(at the end use -l for last container, -a for all container in the system)

$docker ps

Make new images from container:

$ docker commit 1874624g4274u24979j424s44x22y00d //container-id
$docker tag 1874624g4274u24979j424s44x22y00d new-image-name

You can check your new created image by $docker images or via application

Dockerfile : A Dockerfile is a plain text file that includes instructions that docker used to package up this application into an image. this image contain everything that the application needs to run. It is a small program tells how to build docker image.

Run this program:

$ docker build -t end-of-result .

-t represents tag
( . ) represents the current directory

Building Dockerfile:
Open code editor make file as “Dockerfile”
syntax:-

FROM busybox
RUN echo “building simple docker image”
CMD echo “welcome to docker”

Conclusion:

You can find more via running $docker — help and refer them in google
If You are facing any problems feel free to contact me via Twitter LinkedIn

--

--

Diptendu Biswas

Focused and quick learning software engineer. Emerging developer and a night coder.