Understanding Docker – Why, What and How to use it!

Home / Docker / Understanding Docker – Why, What and How to use it!

Suppose you write a text file and wish to open this text file into another environment. Then sometimes it comes up with a warning that this text font is not supported in this environment. But meanwhile you convert that text file into a pdf format and then open the same pdf in another environment. That pdf file have no issues with the environment. Like wise, with the docker, it binds up the different IT operations like code, system libraries, system tools, runtime. It runs on server without any leakage i.e. a full proof solution to server deployment. So, this post is about understanding docker installation and usage.

Why should we use Docker

“Docker achieves agility and control for Development and IT Operations teams to build, ship, and run any app, anywhere”

Agility: Docker gives developers the freedom to define environments, and create and deploy apps faster and easier, and flexibility for IT ops to quickly respond to change.

Control: Docker enables developers to own all the code from infrastructure to app, and the manageability for IT ops to standardize, secure and scale the operating environment.

Portability: Docker gives you choice without complexity, from a laptop to a team, to private infrastructure and public cloud providers.

What is Docker

Docker allows you to package an application with all of its dependencies into a standardized unit for software development.
Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, system libraries – anything you can install on a server. This guarantees that it will always run the same, regardless of the environment it is running in.

Docker is basically a container that we use to ship over. It provides us the facility to run our application anywhere regardless of the environment and other technicalities. It has defined all the things in a wrapped box which is equally secured and ease to operate.

How to Use Docker

Step1: Install Docker on Ubuntu 14.04

sudo apt-get install docker.io

Step2: Build up your project using docker

docker build -t my-project .

Step3: Watch that docker container has your project image

docker images

Step4: Run your application over docker

docker run -d -p 8080:8080 [repository-name]

Step5: View your project running over the docker

docker ps

Step6: View the logs that is bind up in your project

docker logs [image-name]/[container-id]

Step7: Stop the image from being run

docker stop [image-name]/[container-id]

Step8: Kill the image while running

docker kill [image-name]/[container-id]

Step9: Remove the image from being run

docker rm [image-name]/[container-id]

Step10: Remove the project image from docker

docker rmi -f [repository-name]

Some points to take in mind while running docker on your machine.

– If you are using MySQL, you have to change bind-address in my.conf or mysqld.conf from 127.0.0.1 to 0.0.0.0, so that it can accept request from any IP Address.

– You have add port MySQL port

sudo iptables -A INPUT -p tcp --dport 3306 -j ACCEPT

– Verify that your MySQL is accepting request from other IP Address. For that

telnet 192.168.0.6 3306

or,

mysql -h 192.168.0.6 -u newuser -p