So I was planning to write some getting started guides for some trending technologies and frameworks for web applications development.
But, I was totally confused with one thing and that was the Operating System. Because, I don’t want to write getting started guides for all different OS that we commonly use. And this one confusion led me to Docker. As many of you might not know about Docker or might haven’t used it before. Therefore, I decided to help you get started with Docker with a minimum level introduction and installation guide.
So Let’s begin!!
In a nutshell Docker is a platform for developing and running applications. It helps you to separate or isolate your application development so you can deliver softwares quickly.
And docker achieves this isolation using a loosely isolated environment called Container. Container is basically a standard unit of software that packages up code and all its dependencies. It helps you to get started and deliver applications quickly and reliably.
There is another important component of Docker infrastructure and that is Docker Engine. Docker Engine is an open source containerization technology. This is basically which actually helps you build new containers, and hold and run your containers within Docker. Docker Engine consists of three components. 1. A server with a background process or daemon, 2. Docker APIs that help other programs talk or communicate with Docker, 3. CLI or command line interface for Docker.
You can find more details about Docker, Containers and Docker Engine on the official Docker website and Google.
Now let’s see how you can install Docker on your machine. So, you can easily follow most of my future getting started tutorials and also standardized your development process for yourself or your team.
Installation of Docker is very simple and straightforward for both Windows and Mac. Because, we can easily install Docker on both Windows and Mac by downloading just downloading
.dmg files for Docker website and let Docker installer handle everything for us.
Here are URLs for both.
Docker installer, package or application consists of these components or modules for both of these operating systems.
I would highly recommend you to go ahead read more details about all of these except Kubernetes for now. Because, Kubernetes is a whole different entity or process and a crucial part of modern Continuous Integration (CI) and Continuous Deployment (CD) processes. And you should learn or master Docker first before jumping or getting started with Kubernetes.
When it comes to Linux, Docker provides both
.rpm packages for most of the major distros that includes Ubuntu, CentOs, Debian, Fedora, Raspbian.
Although, you can just download, either
.rpm package according to your Linux distro, and install Docker by just double-clicking the installer. But, I would strongly recommend you to follow the process of installing Docker using Linux terminal and adding Docker repository to the repositories list of your machine. Because, when you install an application using a repository, you will not have to worry about updating this application or package in future. As your Linux distro will automatically check for available updates of all repositories including Docker whenever you run the update or install command.
I have created a video tutorial to explain and demonstrate that how we can install Docker on Ubuntu 20.04.
You can also check this page and follow instructions for your preferred Linux distro on Docker website.
Now if you have successfully installed Docker on your machine. It’s time to play around and get familiar with some important yet simple Docker commands.
Just like any CLI, for example Git, WordPress, Nodejs and many others, each Docker command or instruction must begin with
docker. Because, it will tell my operating system that whatever I am going to enter after this is part of Docker CLI and you must go and check the Docker package to see instructions or logic to run this command. Just go ahead and type
> docker --help to see the list of all available sub-commands or scripts available with Docker CLI.
Or you can also run
> docker <COMMAND> --help to see help of any specific command to go deep in details and learn quickly. For example go ahead and try any or all of these.
> docker run --help > docker image --help > docker container --help
There are so many commands available in Docker CLI. But, I would like to discuss two of those here. And the first one is
> docker version. This simple command will help you see the current version of Docker application or package on your machine and some other details. For example below is a screenshot of
> docker version command from my Ubuntu 20.04 machine.
You can see details about both my Docker client and server engines on my machine and your machine if you run the same command on your machine. Go ahead and try it. And may be share it on your Instagram or any other social media account with hashtag #gettingstartedwithdocker just like I did here for this guide.
Another important command of Docker CLI is
run. This command might be the most used command of Docker CLI; Because you use this command to start, create, download and run different Docker containers. Whenever you run this command, Docker will first download the container image if it has not been downloaded already on you machine, create a writable container layer if it has not been created already and then start it.
> docker run command also comes with a lot of different options. I would again encourage you to run
> docker run --help to see all available options for
run command or visit Docker website to see more details.
Docker is a great tool and every web developer should get familiar with it. Because, most of the good organizations and startups have made Docker a part of their development and deployment infrastructure. And learning Docker will definitely give you an edge if you are looking for a job. And it will help you to standardize your own development process if you are working as a consultant (just like me) or own your company (just like me).
Also whenever you want to learn something new, especially something that involves use of a command terminal or shell, always try to go and play with things. Run commands, see help manuals and try experimenting different types of commands and use-cases. And if you are afraid of doing this on whatever machine you use, just setup a virtual machine and practice in it.
And By the way, for docker we don’t even need a separate virtual machine. Because, that’s why we have Docker containers. Just create a new practice container and you will be ready to roll.
I will see you in another getting started guide.
Until then take care. Allah Hafiz.