You should learn docker right now !!

You should learn docker right now!!

You should learn docker right now!!


Hey guys in this blog we will be taking a look at docker | and its uses | creating a container using docker 

What is docker?

Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers.The service has both free and premium tiers. The software that hosts the containers is called Docker Engine. It was first started in 2013 and is developed by Docker, Inc.

Uses of docker?

Docker helps to ensure that all the developers have access to all the necessary bits and pieces of the software they work on. So if someone adds software dependencies, everyone has them when needed.

Why use docker when virtual machines are there? 

Docker is fast. Very fast. While a VM can take at least a few minutes to boot and be dev-ready, it takes anywhere from a few milliseconds to (at most) a few seconds to start a Docker container from a container image.

Installation of docker 

Docker should be installed on your pc in order to use it you can use the Docker's official website to download it for windows or if you are Linux you can install it just by using the command below.


$ sudo apt install docker.io


Docker can be installed on anything like bare pc, raspberry-pi, online cloud server even inside a virtual machine

Using the docker

Installation of docker image

If you are using Linux open up the terminal and run the command 


$ sudo docker pull ubuntu


What the above command is doing is going to the Docker hub which is the public registry for all the containers that are available and downloading it into your system.

You should learn docker right now !!

Running the docker image

After you have successfully installed the docker image, write a command to run it 


$ sudo docker run -d -t --name "name-you-want" "image-name"

 In my case I am going to run the:-

$ sudo docker run -d -t ubuntu-docker ubuntu


You should learn docker right now !!

The above command is running the docker-machine that takes some arguments which are -d ( --deatch means run container in the background and give the container id  ) -t ( --tty means this will allocate you a pseudo - TTY  ) --name this takes the name you want to give to your machine and at last you have to select which image you want to use. 


Listing the containers

To list the containers that are there, there is a command named docker ps which gives the list of containers.

You should learn docker right now !!

As you can see in the above example the docker ps command gives the list of all the containers that are running in the 

Now if you want to go into your docker container you can use the command                           


$ sudo docker exec -it "name-of-the-container" bash

The above command states that execute the ( interactive & TTY ) with the machine name and connect with the bash shell of the machine.

You should learn docker right now !!


As soon as you typed the command you will be in that container within a second, now you can imagine how fast the docker containers are.

Now whatever command you will run on the container it is completely isolated and safe and secure it has nothing to do with your host system.

Just type exit if you want to get out of the container.  


Starting and Stopping the containers

Now Starting and Stopping the container

If you want to stop the existing running container you have a command 


$ sudo docker stop "name-of-container"


You should learn docker right now !!

 Now if you want to start the existing stopped container 



$ sudo docker start "name-of-container"

Deleting or removing the docker containers

If you want to delete or remove a docker container you can also do that, suppose you don't want that docker container anymore you can easily delete that container instead of just stopping it. 


$ sudo docker rm "name-of-container"


You should learn docker right now !!

Conclusion:-

From this blog, we have got a basic understanding of:- 
  1. Installing Docker 

  2. Installing docker image 

  3. Running a docker image 

  4. Starting & stopping the docker containers 

  5. Removing the docker containers 

  6. Executing the docker containers



Next Post Previous Post
No Comment
Add Comment
comment url