Prelogue:
I was hearing about kubernetes application in cloud for quite a bit of time now and have been feeling low about not understanding what kubernetes is. So I headed over to linkedin learning, the awesome platform to learn about kubernetes. But kubernetes courses showed understanding of docker as a pre-requisite. So I started to learn about docker.
Introduction:
Photo by Andy Li on Unsplash
In this post, I want to provide you a preliminary understanding of what is docker and a container; and maybe a basic introduction of few usage and concepts. This is the first part of the learn-docker series I am writing, along with my own learning curve in understanding docker, container, containerization and other processes. Now let's get started with our learning.
what is docker?
Docker is a utility which carves up your computer into small sealed containers which are isolated from outside worlds. It contains its own code, env and all. It also builds these containers for you. It gets the code to and from you. It also opens you up to a social platform where you can find such containers and work on them.
what is a container?
it is a bundle of self sufficient software. it contains everything needed to run on its own. including:
(1) code (2) config files (3) dependencies installed (4) processes (5) networking for talking to other containers (6) even the part of operating system it needs to run
so basically docker takes your code and env and all resources as mentioned and seals it into a container. As well as docker runs multiple such containers in its carved up places, manages the server; and finally tears the whole thing down when work is done.
Installing docker-ce in your machine:
If you are using mac or pc, then you have to install docker desktop. Follow this official link
for downloading docker desktop. In case of linux machines, it is easy
to install docker from terminal using repository method. Follow this official link to get it installed. There can be some problems for download. Follow this stackoverflow discussion.
One and first use of docker:
Not many people let's say use linux machines all the time. So what they may do is that they will run a linux virtual machine using docker. Now you may think that docker is the vm but no. Docker is the software which hosts and holds that vm in your machine and runs it. we will run a small docker program named hello-world.
Troubleshoot:
It may have been the case that you got an error something similar to this:
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.
follow this link, if you don't want to use simple solution of adding sudo before your statement. The risk in the following of the solution mentioned in stackoverflow is that you may have to reboot or log off from your machine; which maynot be a very good choice for you.
Whatever, you must have solved the docker issue and now you must have run the command:
sudo docker run hello-world
This, if your docker doesn't have hello-world downloaded, then will fetch from remote and download, then run. The sign that it has run is the message
"hello from docker!" which pops up in your console.
The same thing can be done writing the command in a mac terminal if you are using the mac or if you are using windows then in your command prompt. If you are facing a socket not found or related issue in mac, then see if your docker desktop is running completely. If it is, it will show that in the top right corner icon.
Now to see a collection of basic usage and commands of docker; write $docker in your terminal. something like this will come up:
If you write $docker info (or sudo docker info for non-root users),then all client and server descriptions and informations will come up.
what is docker id?
I will finish this introductory part by saying one more thing. Docker comes with a online portal too. You can host unlimited public repository and one private repository to host your docker images; using free docker id. You can think about it as a github like platform but for docker images and containers. You should build your docker id now as later on we'll create images and upload them in public repositories in our docker accounts.
Note this, docker id may sound like something you need to find and enter; but docker id is just the username you put. So give a fancy docker id as you wish!
Our next post on this series focuses about docker images.It is yet to come. I am loosely following the learning from linkedin learning's Arthur ulfeldt's course. I will highly recommend his course along side my documents. Thanks for reading! leave a comment below if you like the content!
Comments
Post a Comment