Working With Docker – III

In the previous chapters we learnt some basic docker commands. In this chapter we will discuss about some advance docker commands.

So far you know how to run a docker container in detached mode. Now we will learn some commands to manage the life cycle of the docker containers. Below mentioned commands will help us to manage the life cycle of the containers.

  • create
  • start
  • stop
  • kill
  • rm

Lets start using the above commands to stage the container. First we will create a container. In this example I will use httpd docker image which will give me a Sample Apache Server running inside:

So, we created the docker container and in the output of docker ps -a  command you can see the status of the container is created . Now we will start the container and then we will access the port 80 to see  whether we are able to access it or not.

After starting the container see the out put of docker ps -a  command. Now the status of the container should be Up and you should able to see the port forwarding of the container to the host i.e. 80 -> 80 in our case.  Lets access the Apache webserver using host VM’s IP address.

Well, now let’s stop the container and see the out put of docker ps -a . After verifying the Apache webserver’s status we can again restart it and finally we will destroy it.

Now, we are comfortable with Create, Start, Stop and Restart commands. Finally we will remove the test container.

That’s it we are done with this chapter and in next chapter we will learn about Dockerfile. Using Dockerfile we will build a Wordress docker image and after that we will run a container using that image to access the WordPress.

The following two tabs change content below.

Tapas Mishra

Sr. Engineer (DevOps)
Loves to work on Opensource products. Having experience on Linux environment. Knowledge on Public cloud services like AWS, Rackspace, DigitalOcean, Linode. Please don't hesitate to give a comment on the posts. Your comments are my strength.

Latest posts by Tapas Mishra (see all)

Leave a Reply