Mastering Docker, Chapter 1: Docker Review

Understanding Docker

Difference Between Docker and Typical Vm's

Docker is a linux container (LXC) management system.  Like other virtualizion strategies, it allows you to create a self contained sandbox that just works on a server, since theoretically everthing else is the same.  Unlike virtual machines, Docker containers do not need an entire operating system to run.  This makes them smaller and easier to use ship.

Dockerfile

The Dockerfile contains all the instructions to be performed when an image is built

Docker Networking/Linking

Docker containers are linked together through bridged network adapters.  Communications are through these bridged adapters, so you don't have to expose ports for different containers to talk to each other.  This can be a safer method of using docker containers, than using vm's.

Docker Installers/Installation

There are four different environments you can install Dock in:
  • Apple OSX
  • Microsoft Windows
  • Linux (all flavors)
  • Cloud 

Types of Installers

Docker used to use a command called:
boot2docker

Docker has moved away from using this command, but it's good to know how to use it, in case you need to work on an older system.

Controlling the Docker VM (boot2docker)

There are all kinds of commands, the one you need to worry about is

boot2docker help

Docker Machine - The New boot2docker

The new commands are:

docker-machine

Again you can use:


docker-machine help

Kitematic

Kitematic allows you to manage your containers using a GUI.  This only works on Windows and OSX.  The following github project https://github.com/docker/kitematic/releases is supposed to be a version that runs on a linux machine.  I found this blog that also shows how use Docker Kitematic on linux.

The Docker Commands

There are three commands discussed here:
  • docker help -- does what you think it should
  • docker <command> help -- shows all the different options for a docker command
  • docker version -- shows the version of docker you are using

The Docker Images

To view what images you have type in

docker images

This will give you the following information:
  • Repository: name of the repo as it exists on the Docker Hub
  • Tag: This will show you what version you are using.  You can specify a specific version in the Dockerfile, which allows you to test on different versions of an OS
  • ImageId: 64 bit unique key for an image
  • Created: When the image was created
  • Virtual Size: The size of the image

Searching for the Docker Images

You can search for docker images using

docker search 

When you find an image you want to user:

docker pull 

You can remove an image with:

docker rmi repo:tag

Manipulating the Docker Images

To turn an image into a container run the following command:

docker -run -it  /bin/bash

to test the image.
  • -i : gives puts us in interactive mode
  • -t : gives us an terminal into the image

docker run -d 

will run the container in daemon mode.

Running

docker ps

will allow us to see what containers are currently running.  We can use -p switch to expose ports from our container

docker logs container_id or container_name

To view the logs of the container

Stopping Containers

There are four commands to stop a container:


Comments

Popular posts from this blog

Go Programming Blueprints, Chapter 2, Adding User Accounts

Successful Big Game Hunting Chapter 10