Diving Into Containers

WARNING!!!!!! Straight from the Mad Scientist!!

Part 2

No were not talking about dumpster diving ….but close. I don’t know about you , but I am a conceptual thinker. Give me the “headlines” (and google) and I can usually figure things out. If you’re not wired that way, along with the book mentioned in Part 1, you can also find some awesome documentation over at docker.com.

OK, Part 1 left you with some homework. Did you set up your github and dockerhub accounts?…….OK….I’ll wait……go do it now!!!!

Conceptually, docker has three basic parts. Docker images (plenty to pull off of dockerhub.com), The Docker client (docker command) and the docker host (server) running the docker daemon. Most of the interaction is with the host using the client commands. Below you will see a simple model of docker.

docker_machine

At this point you should have a new Ubuntu:Mate workstation and the docker deamon installed. If you were to use the $ sudo docker images command you should see a few local images. These were pulled down from dockerhub when we tested the docker install in Part 1. Here is an example of my current system.

docker_images

You will probably notice the xod442, this is my dockerhub account name. Followed by a slash and the name of the Docker image. If you want to remove one image you can use the $ sudo docker rmi (image_name) command. If you would like a clean slate and delete all of the images you can use the $ sudo docker rmi $(sudo docker images -q), and say good bye to all your images. I used this several times in my learning process.

We briefly touched on the command to get us into a new container. We used $ sudo docker run -i -t ubuntu /bin/bash. The /bin/bash tells docker to do something and keep the container running. Without it the container would start and stop very quickly. You can use the $ sudo docker ps -a command to see the status of all containers. Without the -a option the command only shows running containers. In the graphic below I show the commands to start a new container and break down what is happening. I also show how to get out of a container (exit) and how to commit the changes that you make to a container, creating a new docker image (this is the point where the dockerhub account is going to come in handy.

docker_in_out

Here is a diagram of the process. Using the docker run to initialize a new container, adding some extra love to it and committing to a new docker image. They say a picture is worth a 1000 words but this one is most likely 385. Remember concepts/headlines only!!!

docker_create

I think this is a good breaking point. I urge you to go out to docker hub and browse some of the pre-built images. No need to reinvent the wheel, there are plenty to toys to play with. One last tip before we sign off. Use the $ sudo docker search (keyword) to look for specific images you might be interested in. You just might find what you are looking for. Finally if you want to get something you find on the dockerhub site, use the $ sudo docker pull (user-name/image_name) command to pull it down to your docker host.

Part 3 will be a docker survival kit!

Leave a Reply