Travel in Docker

Travel in Docker

Let’s learn the definition of docker in as simplest way as possible.

What is docker?

Docker is a creamy layer on oreo, means it act as a safe layer on your base OS (maybe Linux, Windows or Mac). So, you have your computer or server (computer on which your code and app will reside) on which any os is running, every os has it’s filesystem and configurations to interact with hardware and physical resources, now when you will install docker on that, it will create its own filesystem providing you with the virtual space to work with and interact with the physical resources, which will be fully isolated from your base os.

The interesting thing of docker is, it is independent of the os, it can be easily migrated to one os flavour to another.

Now, this is not the only the reason we use it when you go deeper inside you will get to know the ease of working with docker, it basically installs the packages independently on the filesystem and totally isolated in a container (called docker container).

For example, if you are using windows as a base os on which docker is installed, so now for any reason you need ubuntu (Linux) on windows, so basically what you will do, first you will install a VM (virtual box,hypervisor or VMware etc.) then you need to download a ubuntu os, afterwards you need to install that ubuntu os on VM, now you will be able to get access of your desired OS, so many steps and little bit tricky for beginners, but if you are talking about docker you just need to run “docker build” command with tag name “-t” in directory where you have created the “Dockerfile” and your ubuntu image will get created.

Now, what is Dockefile?

It’s just of code file with few Linux command on it nothing apart from that, for example, if you need to install “Ubuntu”, just create “touch Dockefile” do “vi Dockefile” and type there “FROM Ubuntu:latest or FROM Ubuntu:16.04″ now save the file and run the command mention above, it will create an image of Ubuntu with image id, for taking the access of that image (ubuntu os) just need to type “docker run -it {image id} bash”, you are in into your os that’s it.

Now little bit of tricky part !!!

 Before moving further I want to mention few things here the way you have created your ubuntu os image, the same way you can create an image of Nginx, Apache, python etc individually with their dependent package, you just need to go through few of the command like “FROM, RUN, COPY, ARG, ENV, etc. ”

If you want to install Nginx, without docker you first need one base os like (Ubuntu), now you need to install Nginx on it, but in docker just do the same thing above, “FROM nginx:{version}-{alpine or leave it blank}” , save the Dockerfile and run docker build command and done now your image is created.

Docker compose

It’s just a small code file in .yml extension, where you need to describe that you are the son of your parents (Keys: Values) and you want to communicate to you uncle (another service) through some particular port “out_port:in_port” and done. Now run the command from the directory where you have created your docker compose.yml file like “docker-compose up -d” and done your container will get created with its image with proper inter-link communications on your specified port.

***For more pieces of information about a docker-compose file just go to https://docs.docker.com/compose/gettingstarted/#step-3- define-services-in-a-compose-file

and search “Step 3”, you will get the idea of writing it.

Docker swarm

For better understanding about Docker swarm, I will suggest you there official documentation, follow the link to learn more.

https://docs.docker.com/engine/swarm/

ASKOPS APP IS NOW AVAILABLE ON PLAYSTORE

Askops
Askops
Developer: Nikhil raj
Price: Free

Leave a Reply