admin/ April 22, 2017/ Docker, Linux/ 0 comments

What is Docker?

Docker is the secret weapon of developers and IT ops teams everywhere, allowing them to build, ship, test, and deploy apps automatically, securely, and portable with no surprises.

What is Docker Container?

A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Available for both Linux and Windows based apps, containerized software will always run the same, regardless of the environment. Containers isolate software from its surroundings, for example, differences between development and staging environments and help reduce conflicts between teams running different software on the same infrastructure.

How to create docker image ?

Step 1: Create a Dockerfile.

Step 2: Write docker statement in the file “Dockerfile” for example as below.

FROM -: FROM is used for default base image (OS) used in the Dockerfile

MAINTAINER -: MAINTAINER is used to give the name of image maintainer.

RUN -: RUN command is used to execute the command while building the image

EXPOSE -: EXPOSE command is used to expose the port which can be used in the container.

CMD -: CMD command is used to execute the command while launching the container.

How to build the Docker image using Dockerfile?

To run the docker container

For example-:

In the above example we have used “docker run” command to run the docker container, “-d” is used to run container as daemon and “-p” or “-P” is used to published port.

To Stop running container

The above command will stop the running container. You can get the docker running containerName or ContainerID using the command ” $docker ps”. This command will show you the running container.

To remove the container use the below command.

You can remove the stopped container using the above command.
If you want to remove forcely a container. You need to use command as below.

To Remove the Docker Image

To get the Docker Image Name or Image ID, use the command “$ docker images”.
This command will show you all the images. You can use Docker ImageName with tag name or Image ID of the docker image. If you are using ImageName you must give the tag name if you will not give any it will use “latest” as default TagName in the docker.

To remove the image forcely, use the below command.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.