Docker Introduction
If you’ve been following trends in the “cloud” world, you’ve probably heard of Docker. It is “an open source project to pack, ship and run any application as a lightweight container.” The container is a standard packaging of applications. The idea is to provide a comprehensive abstraction layer that allows developers to “containerize” or “package” any application and have it run on any infrastructure.
The most common analogy used to help people understand is saying that Docker containers are like shipping containers: they provide a standard, consistent way of shipping just about anything. Their containers provide a standard, consistent way of packaging just about any application.
What is a docker image?
In Dockerland, there are images and there are containers. The two are closely related, but distinct. For me, grasping this dichotomy has clarified Docker immensely.
An image is a essentially a snapshot of a container. Images are created with the build command, and they’ll produce a container when started with run. Images are stored in a Docker registry. Because they can become quite large.
Containers are the hottest trend in data center innovation. To use a programming metaphor, if an image is a class, then a container is an instance of a class — a runtime object. Containers are lightweight and portable encapsulations of an environment in which to run applications.
With the rage of Docker Linux Containers — we should remember that container technology has been around for more than a decade and is an approach to software development in which pieces of code are packaged in a standardized way so that they can quickly be plugged in and run on the Linux operating system (OS). This enables portability of code and allows the operating system to be virtualized and share an instance of an OS in a same way that a virtual machine would parcel up a server.
To list all the containers,
$ docker ps
Working:
Listing images
To list all the images,
$ docker images
Searching images
To search an image
$ docker search <image-name>
Pulling images
To pull an images,
$ docker pull <image-name>
Running images
To run image,
$ docker run <image-name>
To stop image
$ docker stop <container-id>
Building images
Following are the steps to build a docker image,
- Write a Dockerfile
- Build an image from Dockerfile
$ docker build -t <image-name> .
3. Run your new docker image
Sign Up to Docker Hub
- Use your browser to navigate to the Docker Hub signup page.
- Fill out the form on the signup page.
- Press Signup.
- Open your email inbox and click the Confirm Your Email button.
Now configure docker login, for that use command,
$ docker login
Enter your credentials
Pushing images to Docker Hub
List all images and Verify name
$ docker images
Fire push command
$ docker push <image-name>
Verify at Docker Hub console for new image.
Deleting docker images and containers
To remove image,
$ docker images
$ docker rmi <image-id>
To remove container,
$ docker ps -a
$ docker rm <container-id>
Till now, it was all about important and most used docker definitions and commands on Linux systems. And this brief introduction holds the basic level understanding of docker. Hope you enjoyed this article, and I wish you get a idea about what docker is and how simple it is.
Stay tuned for more articles!
