03 - Docker Advanced Usage - Advanced Docker Containers commands

we'll explore some of the more advanced commands that you can use from the command line to discover a great deal about your Docker containers both the containers that are currently running and those that happened to be stopped.
 
Let's start with help, although you don't type help. You type "sudo docker" and then any command, the command you'd like to find out about. Let's say inspect. The syntax is "docker inspect" then the container and/or image name. Let's try inspect but first we'll have to find out what Docker containers are actually running on our system. We'll use "docker ps." There's one container currently running. It's called "Compassionate Morse" but it also has a container ID of 5EE, etc.
  Inspect and monitor Docker containers 
Let's type "pseudo docker inspect" and then paste in 5EEF. And we are shown a great deal of data covering the environment values and operating system architecture that this container happens to be running with. Docker logs when applied to a particular container will provide a record of session activity. Sometimes there might have been a great deal of activity in a particular container too much really to view comfortably on a screen so you can always pipe the output to a text file or to less.
 
Let's again run "sudo docker ps" to see what containers are actually running and again there is just this one container currently running. And let's use "docker port" to see whether port 22 happens to be open and listening right now. Apparently not. Port 22 by the way is the port, which is set aside for SSH traffic. So SSH is currently not available from inside this container.
 
History is the command that will, as you can probably guess from its name, display some of the event history of a particular container. Let's take Busybox:latest which was one of the smaller images that we built. So we see it was originally created some 14 months ago with some work done on it about three months ago. This is before we actually downloaded it and worked with it ourselves. But this is some we developed in history of the image itself.
  How to manilupate Docker containers via console 
Let's explore some commands for manipulating Docker containers, not just seeing what the container status configuration is but actually working with data in the containers. Let's try "cp," "sudo docker cp" which as its units equivalent will copy a file. This will copy a file from a container.
 
The name given to one of the containers currently on my system is evil goodall. I will take let's say the host name file from the container evil goodall and I will copy it to this directory, the directory on the host where we happen to be right now. Let's take a look and in fact we see the host name file is there and I think we can safely assume that it's the host name file from this container evil goodall. Let's see what's running right now. Sudo docker ps this will show us all the Docker containers currently running. There's at this point only one. It's Apache-A or as Docker describes it angry_lalande.
 
Let us pause this container using "sudo docker pause", pause angry_lalande. Let's take another look at the running Docker containers and angry_lalande is still there but if you look under status it's up two hours but currently now it is paused. It's perhaps not entirely intuitive but you can restore or restart a paused container with the command "unpause," "sudo docker unpause" and then the name of the container, which seems to have worked. And again let's take a look at the list of running containers and this time angry_lalande is up and running with no paused flag next to it.
  Remove Docker containers and images 
Finally, let's explore how to remove Docker containers. "Sudo docker ps -a" get a list of all the containers currently on our system to see if there's something that is perhaps expendable and I will nominate elegant_davinci for removal. So "sudo docker rm elegant_davinci." Let's run "ps" again and elegant_davinci is nowhere to be found. We've removed that container. However, that's just a container. Perhaps at some point we'll want to remove an image to find out what images currently are on our system. Of course, you run "sudo docker images." We'll remove the quay.oi/dbclintion quay/first image, which we had worked on in a previous video. To do this "sudo docker rmi," not "RM" for remove but "RMI" for remove image and lets rather than typing the whole thing. Let's highlight quay.io control shift and C to copy then control shift and V to paste which again is a quick short cut for moving text around within a console and enter. It seems to be deleted. Once again, we'll take another look at images and there's no more quay/first image.

Comments

Popular posts from this blog

Cloud Computing in simple

How to Write an Effective Design Document

Bookmark