Dockerize — Learning Docker Series 2

Covenant Chukwudi
MyCloudSeries
Published in
4 min readFeb 13, 2019
Dockerize series

This is a continuation of our Learning Docker Series 1.

In addition to where we left off in our last section is this special command which enables you access the shell of a container:

docker container run -it --name CovenantServer tomcat bash

Container Networking

When you start a container as we’ve done in the previous examples from our series, your container would normally connect to a private docker virtual network called “bridge”.

All containers within the same virtual network can communicate with each-other without you using the “ — publish” attribute to open up a port to your host computer.

Docker virtual network routes through the NAT firewall on your host computer to enable your container access the internet or networks on your host.

We will still discuss a lot more about container networking in upcoming series.

Images

One of my favourite Docker Champion, has a perfect definition for an Image:

An Image consists of the App Binaries, Dependencies, Metadata about the image data and how to run the image

Docker hub has an enormous repertoire of images for just about anything, these images can be used just as they are, they can be customized and extended for any purpose whatsoever that you might need.

If you don’t have an account with Docker Hub, head over to https://hub.docker.com and create an account.

Docker Hub sees a lot of contributions daily to it’s images repository, we have official images (images that are supported and maintained by Docker core teams ensuring quality documentations, standard testing, swift bug fixes & releases) which you would notice as having the “official image” badge on it and their names are usually without any forward slash.

For-example, the official Tomcat image has a label of just “tomcat”,

an “official” image in the docker-hub repository

Meanwhile, a non official image of Tomcat would normally look like this:

a non official docker image on Docker-Hub, has a forward slash in it’s name and has no “official image” badge

Tags

Docker Images have an interesting concept of “tags” associated with them. Tags are properties used in combination with an “Image Name” to describe an Image.

You can easily identify Tags by reading the aspect of an image name that is after the colon(:)

covenant/laravel:devbuild

In the above example, “devbuild” is a tag associated with the image “covenant/laravel” (Laravel is a php framework for rapid development of web applications).

Tags are used extensively as a versioning system. They are used to keep versions of an Image.

In our initial example of “covenant/laravel” image, we can also have another “version” of the same image with some modifications or extensions, probably uses nginx as the webserver instead of apache and call it “covenant/laravel:newbuild-nginx”.

If for any reason we need to use the initial version, we simply use the “:devbuild” tag. This is how “Tags” helps us to categorize images, label images and keep versions of images.

You can see some of the tags of Apache tomcat here:

optional tomcat tags

To pull an image of tomcat 8.5.38 with jre8, we simply do this:

docker image pull tomcat:8.5.38-jre8

Sticky Notes

  1. Docker creates a virtual network by default called “bridge”.
  2. Each container created with the default settings are created within this virtual network.
  3. Containers within the same virtual networks can communicate directly with each other without a port being published to the host computer.
  4. Containers are able to access the internet, by routing requests through the NAT firewall on your host computer. Even if they are in a virtual network.
  5. A docker image is a composition of application binaries, dependencies and metadata about the image and how to run the image.
  6. Docker images use tags as a means of versioning images

Next Up

In the next series of articles, we would continue our journey by delving deeper into Images, concept of Image Layers, creating our own images and so much more.

Hire Me

Have an interesting project? Great!, shoot me an email at covenantchukwudi@gmail.com.

--

--

Covenant Chukwudi
MyCloudSeries

I build products that would have positive effect on lives