Introduction

If you are in IT, irrespective of the role you play, be it general management, sales, development or operations, the chances that you use or hear the word "containers" in your work life are very high. Container technology is not new but has garnered a lot of attention in the last few years, thanks to Docker. Docker, which has become synonymous with container technology, has made container technology more accessible and has been a primary driver of adoption of the container technology.

In my work life, I often talk about the benefits of containerization and why enterprises should accelerate their adoption.Though most understand the technology,many struggling with the understanding of the value argumentation.To be honest, initially, I struggled as well. It all changed after I invested some time to get some hands-on experience.I did a couple of side projects with my Raspberry-Pi that was not only fun but also allowed me to appreciate these technologies much better.

One last note befre you dive in.This post is not meant to be a comprehensive tutorial but a sincere attempt to get you started (excited!) and hopefully enable you to explore, experience and appreciate the technology in a fun way.

Key Docker Terminologies Explained

Before we dive in, it's important you spend a little time on some of the docker terminologies. It will help you understand the commands better.

Images

It is simply a package that consists of all dependencies and information required to create a container.For example,this blogging platform (ghost) is built around this tech stack.The docker image of ghost will simply package all the necessary libraries across the entire stack into an image.The end user is relieved from managing the dependancies, libraries et al. and simply use the image to create a container.

Containers

Container is an instance of an image. It consists of an image, execution environment and some set instructions for the container.

Volumes

It is important to remember that containers are ephemeral. So, if you shut down down your container, you lose everything in it.Most applications need to share and access data even if the container gets deleted and this makes container impractical in such situations.The solution lies in volumes. Volumes are nothing but directories that exist on the host system.

Repository

Collection of related images

Registry

A service for hosting and distributing image.It can be hosted as a third part, public or private.Docker hub, Google Container registry, AWS container registry are some examples of registeries.

Pre-requisites

* Raspbian Jessie installed. If you are new, you can find the installation instructions here.
* Raspberry Pi secured.Again, if you are new, you can simple but detailed instruction on securing your raspberry pi here.
* Patience! Sometimes, some of the commands listed below may not work as intended. Do check out the references for troubleshooting.

Installation steps and examples

Install Docker

1 : Prepare Raspberry-Pi
sudo apt-get upgrade && sudo apt-get upgrade
2 : Install docker
sudo curl -sSL https://get.docker.com | sh
3 : Enable docker
sudo systemctl enable docker
4 : Add user to the docker group. Replace with your user name.In most case, if you have not changed, it will be "pi"
sudo usermod -aG docker username 
5 : Restart your Raspberry-Pi and start docker
sudo reboot now
sudo systemctl start docker

Using Docker

1. Check docker version and general information
docker info 
2. Check docker commands
docker
3. Now, let's run your first image.
docker run hello-world 
When you run the above command you would a message that the system is unable to find the image locally and starts downloading.The image is actually downloaded from the docker hub. Please note that you do not to login to the docker hub to download image. You need to login only when you want to upload images.

Search & Pull Images

1. Let's search the image for nextcloud image that we will running later.
docker search nextcloud
2. Look for the image arm32v7/nextcloud and pull the image. This is the relevant image for Raspberry-Pi.
docker pull arm32v7/nextcloud
3.You can see the image list using the following command
docker image ls
4. Now, let's go ahead and run the container
 docker run -d -p 8080:80 arm32v7/nextcloud 
Now, you can access the application at http://localhost:8080 from your local host. You can also get multiple options on running your container from the official docker hub link as well.That's about it. You now have your first application up and running. Check out the docker cheat sheet for more commands and explore docker.You can check out Digital Ocean tutorials on working with containers and volumes referenced below. Hope you find this post useful. I will shortly be posting my learning on another fun project (hosting your blog on Raspberry-Pi just like this one).Stay tuned.

References

1. Digital Ocean - working with containers
2.
Digital Ocen - working with volumes
3. Docker cli commands
4. Docker Architecture
Disclaimer : This post does not represent the thoughts,intentions, plans or strategies of my employer.It is solely my opinion.Feel free to challenge me, disagree with me and share your thoughts in the comments section