Today Lets Talk About Docker. As You Have Read In Earlier Blog, What Exactly Docker Is ?
Now lets talk about next question, What makes Docker so attractive & how does it work ??
Answer is, 10 Years ago, when virtual machine started at that time we realized that virtual machine shared the same hardware with the base machine, while testing if the virtualized machine goes down then it doesn’t effect our host machine, that was the motto of creating a virtualize machine and there are lots of applications which needs their own environment to run. If basically i say in short, so virtual machine is a resource through which we can create an elusion for app that it has its own environment. But even at that time base machine had enormous load of various virtualized machines, to overcome this situation a new application has been launched named as docker.It is very light weight application and shared the kernel with the base machine in another words it virtualized the environment rather than virtualizing a machine.
The main thing i would like to share with you is we have to install Docker application and then we can run 10-15 containers or more than that on the single base machine without any problem.
Like in our Laptop we cant install 10-15 virtual machines as various applications needs there own environment. So, in your laptop if there is docker installed, then you can work very easily anywhere around the world. It does not have any dependency issue.
one more thing which is important to know is Docker containers can use its own ports like you have two docker containers and both containers are having apache2 application on port 80, so you can run both the containers of apache on different ports at any time.
Docker is very helpful to create an isolated environment.
[DOCKER IN DOCKER’s TERM…]
BUILD ONCE, CONFIGURE ONCE & RUN ANYWHERE……..
There is also one more component in docker is DOCKER INDEX….
You must be thinking what Docker index is ??
Lets talk about the docker index, it is basically a git repository that contains docker containers and all. You can push containers in that repository or pull containers just like git.
These all points make Docker so attractive….
Now lets talk about how does docker work ?
Let me tell you one thing that Docker’s commands are too simple and user friendly. You only just need to understand the flow of its commands.
ok lets install docker in your ubuntu os machine….
First open the terminal and go to root user by typing:
sudo -s
then update your system by typing:
apt-get update
after updation type the command mentioned below & install the required package:
sudo apt-get install linux-image-generic-lts-trusty
Now reboot your system once by typing:
reboot
Now check curl if it is not installed then type:
apt-get install curl
Get the latest Docker Package with mentioned command:
curl -sSL https://get.docker.com/ | sh
now verify the Docker if it is installed or not, type:
docker version
docker version should be 1.8.2 or higher.
[Note: you can get lots of way to installed docker in just few commands but to install updated version of docker, follow the procedure.]
Now lets learn how to run docker…..
firstly you have to download docker’s image like i want to download ubuntu-14.04 image then download it by typing:
docker pull ubuntu:14.04
it will pull the image from docker hub
After pulling it, you can list the images by typing:
docker images
it will show you the complete downloaded images which you have in your system
after that just hit the command to use docker’s image:
docker run -i -t ubuntu:14.04
that command will give you terminal and then you can run or install whatever you want, but remember after installation if you want to save the changes, you will have to commit the container and for this you have to open another terminal & from root user type:
docker commit your_container_id your_container-name
now the question arises that how do we get to know container’s id & container’s name ?
you can check your container’s id and name by typing:
docker ps
after committing it, your container is ready to use.
[ Note: Remember one thing that without committing your container don’t exit from it & run another one otherwise you’ll loose everything what you have worked in it and next time when you will run it, you will get a fresh copy of your previous container, so docker commit is must to save your work in the container”
now if you want to run your container in daemonize mode then you have to hit the command:
docker run -i -d container_name
To stop running container:
docker stop container_id
To remove container:
docker rm container-id
All basic commands are:
attach:-Attach to a running container build:-Build a container from a Dockerfile commit:-Create a new image from a container’s changes cp:-Copy files/folders from the containers filesystem to the host path diff:-Inspect changes on a container’s filesystem events:-Get real time events from the server export:-Stream the contents of a container as a tar archive history:-Show the history of an image images:-List images import:-Create a new filesystem image from the contents of a tarball info:-Display system-wide information insert:-Insert a file in an image inspect:-Return low-level information on a container kill:-Kill a running container load:-Load an image from a tar archive login:-Register or Login to the docker registry server logs:-Fetch the logs of a container port:-Lookup the public-facing port which is NAT-ed to PRIVATE_PORT ps:-List containers pull:-Pull an image or a repository from the docker registry server push:-Push an image or a repository to the docker registry server restart:-Restart a running container rm:-Remove one or more containers rmi:-Remove one or more images run:-Run a command in a new container save:-Save an image to a tar archive search:-Search for an image in the docker index start:-Start a stopped container stop:-Stop a running container tag:-Tag an image into a repository top:-Lookup the running processes of a container version:-Show the docker version information wait:-Block until a container stops, then print its exit code
3 comments