How to Install Dockers - Linux

How to Install Dockers - Linux

These days, the words "dockers" and "kubernetes" are very common to hear if you work in IT. Many applications are preferred by devs to use dockers nowadays. I work with deployment of two distinct applications that need dockers to work. Those applications are Dell EMC PowerProtect Cyber Recovery and Cyber Sense. If you want to know more about these applications and what they do, you can take a look here.

So, naturally, I also became curious about what dockers are and what they do. So, I started reading up on them, watched some youtube videos, and now, I am midway thru a formal docker training at the end of which I hope I learn dockers and kubernetes properly.

So, I have installed CentOS, RHEL, OpenSUSE etc. VMs on virtualbox in my Ubuntu desktop. Then, I installed dockers on all these OSs. Installation of docker is pretty straightforward and is documented very well at dockers.com. Here is just my experience of the whole exercise of installing docker and docker-compose on CentOS 7.9 and CentOS stream 8.x VM. The process is largely the same with a very small difference as pointed out below. I will update this for OpenSUSE at a later date. As for debian based desktop OS, installation of docker on e.g. Ubuntu can be done simply using apt-get install as the docker installs are made a part of the official repositories, so that one is very VERY straightforward.

One more important thing to know is that docker comes in two flavors: Community Edition (CE) and Enterprise Edition (EE). Docker CE is completey free to use, while Docker EE requires a license and is most suitable for Enterprise OS's such as SUSE and RHEL, but this is not to say that only one edition is compatible with a given OS. Docker CE and Docker EE can be installed on any supported OS. Docker CE has all the features that Docker EE has, the difference is only that EE gets paid support which means a user can basically get official technical support for Docker from the vendor. I am, of course, going to use Docker CE for installation.

All right, here is what we will need to install Docker CE:

  • Create a free account on docker.com (Not mandatory for our purposes, but good to have as it will give us access to docker hub)
  • A CentOS based machine, bare metal or VM. I am using a CentOS VM installed on virtualbox with the following resources. Of course, resources will vary depending on the apps that are to be used, but since this VM is just used for installation of dockers and nothing else, these resources are going to be okay.

CPU - 4 vCPUs
RAM - 2GB
Disk - 22GB

  • Install yum-utils and add a repo that has docker packages. Double check the repo link on docker.com as it can change over time

lordvader@srvcent09 ~$ sudo yum install -y yum-utils

lordvader@srvcent09 ~$ sudo yum-config-manager?? --add-repo \? https://download.docker.com/linux/centos/docker-ce.repo        

  • Install docker-ce and docker-ce-cli. The second package provides CLI interface to manage and administer docker

lordvader@srvcent09 ~$ sudo yum install docker-ce docker-ce-cli containerd.io        
This is where CentOS 7.9 and CentOS Stream 8 will have a difference. Its a known issue as on June 2021 that the repo and docker version has conflicts. Workaround is to use --nobest and --allowerasing options in the command above while installing on CentOS 8 Stream

  • Add dockers to start up on boot

lordvader@srvcent09 ~$ sudo systemctl enable docker.service

lordvader@srvcent09 ~$ sudo systemctl enable containerd.service        

  • Verify docker install by running the following command which will download hello-world image from docker hub.

lordvader@srvcent09 ~$ sudo docker run hello-world        
No alt text provided for this image

  • One interesting thing to note is how docker installs its own virtual network adapter (run ip a or ifconfig).

No alt text provided for this image

Running docker ps will show the images currently running on this VM

No alt text provided for this image

Notice the overlay in the output of df -h. This is basically the storage driver that docker uses to cache the images locally. But this discussion is for another day.

At this point, docker installation is complete and basic docker images and containers can be used. However, there is another very popular tool which is recommended to be installed known as docker-compose that among other things, uses yaml files to deploy images instead of docker commands. Very useful tool. Install it by running the following command (double check the link as it will change with every new release:

lordvader@srvcent09 ~$ sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

lordvader@srvcent09 ~$ sudo chmod +x /usr/local/bin/docker-compose        

So, there you have it folks, a fully functional docker enabled Linux VM ready for container deployments. I am deploying a simple web application that uses NodeJS and React on AWS, but that is for another day.

PS: Some bonus docker commands:

  • docker ps - lists images currently running
  • docker create
  • docker start -a
  • docker prune <container ID>
  • docker logs
  • docker stop <id>
  • docker kill <id>
  • docker exec -it <container ID> <command>

it - provide input
???used to run many similar apps and run??commands on a particular instance
Ruhail Vakil

Principal Consultant at Dell Technologies

3 年

Thanks for taking time to share your learning ! Appreciated

要查看或添加评论,请登录

Kamal Gupta的更多文章

  • Personal Cloud on Raspberry Pi using NextCloud and Ubuntu

    Personal Cloud on Raspberry Pi using NextCloud and Ubuntu

    I bought a Raspberry Pi about 8 months ago, back in december 2020. I bought it because, I wanted to learn linux and I…

  • Configure Swap Space and Hibernation in Linux

    Configure Swap Space and Hibernation in Linux

    Typically, swap space is something that is taken care of during the server deployment, however, there are situations in…

  • DNS Server Config CentOS 8

    DNS Server Config CentOS 8

    1. Configure the firewall firewall-cmd --permanent --zone=public --add-service=dns firewall-cmd --reload 2.

    3 条评论

社区洞察

其他会员也浏览了