Docker Installation And Setup: Best Practices For Security

Before we go into Docker, let's talk about virtualization, virtual machines, and containers.

What exactly is Virtualization?

What exactly is a Virtual Machine?

What exactly is a Container?


We can use virtualization to run many servers (Windows, Red Hat, Ubuntu, and so on) on top of a single physical computer, and virtualization occurs at the OS level.

A virtual machine is a "virtual" version of a computer that uses dedicated CPU and memory from the host system or computer.

Advantages

Cost: We are building VMs on top of a single computer, saving infra costs.
Maintenance: Simple because we just have physical machines.
Isolation: Each VM is autonomous and separate from the others.

Disadvantages:

  • Significant weight.
  • CPU and RAM utilisation are really high.

Containers

Which contains the application-level code that bundles together all of the dependencies needed to run your application.

Application Code:

  • Jar, war, ear, etc.

Dependencies:

  • Java, Tomcat, Angular, etc.

Advantages:

  • Containers are lightweight.
  • Resource consumption is very low.
  • Deployment is very fast and secure.

What exactly is Docker?

Docker is a containerization technology that uses containers to bundle your app and all of its dependencies or

Docker is a containerization platform that packages your app and all its dependencies together in the form of containers.

Docker is an open platform that allows developers and system administrators to create, deploy, and execute distributed applications.

Docker comes in two flavours.

  1. Enterprise Edition (EE)
  2. Community Edition (CE)

Docker Enterprise Edition (EE) is intended for enterprise development and IT teams responsible for building, shipping, and running mission-critical applications in production at scale.

Docker Community Edition (CE) is perfect for developers and small teams who want to experiment with container-based programmes and get started with Docker..

Installing Docker:

  • Docker Desktop
  • Docker for Linux: Ubuntu
  • Docker for Mac OS X

Docker Desktop

Docker Desktop is a one-click installation application for Windows, Mac OS, and Linux, and the installer is available for download from the official website.
Then, to download and install, follow the on-screen directions. If you have any problems while installing and require assistance, please leave a comment below and we will assist you.

Docker for Linux: Ubuntu


Before installing Docker, use the following command to see if Docker is already installed on your Ubuntu machine.
$ docker info

If Docker was installed, this command will provide information about your installation; otherwise, it will display "Command 'docker' not found" and an installation hint.

Docker installation requires the following prerequisites

  • OS requirements: Docker requires a 64-bit version of Ubuntu Server to be installed.
  • If you have any docker, docker.io, docker-engine, containerd, or runc installed, uninstall them.
$ sudo apt-get remove docker docker-engine docker.io containerd runc
 
And then run the following command to install Docker on your Linux machine.

$ sudo curl -fsSL get.docker.com | /bin/bash



 
After installing Docker, use docker info to check.

$ docker info 



Permission denied errors may occur until the user is added to the Docker group. To add the user to the Docker group, use sudo docker info or the following command.
 

Note:
When you installed Docker, a Docker group was created.

sudo usermod -aG docker ubuntu



$ sudo docker info 



Docker for Mac OS

As previously described, we may install Docker Desktop for Mac OS from the command line using the Homebrew package manager.

  • Open your terminal by pressing command+spacebar and then typing terminal.
  • Install the Homebrew package manager in your terminal by using the command below.


$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”


After installing homebrew, run the following command to install Docker on your Mac OS.

$ brew cask install docker

After a successful installation, use the docker info command from your Mac terminal window to validate the installation.

$docker info 




That concludes the Docker setup and installation procedure.
 
I hope you liked reading this article, and I have provided full steps for getting started with, installing, and testing your Docker setup for Windows, Linux, and Mac.
 
Docker is a containerization platform or software that contains your application code and all its dependencies (environment, libraries, and code)  or
 
Skill Up: Developing your skills to the next level.

Docker commands

  1. docker info
  2. docker --version
  3. docker pull
  4. docker run
  5. docker ps
  6. docker ps -a
  7. docker exec 
  8. docker stop
  9. docker kill
  10. docker images 
  11. docker rmi

docker info:
This command returns information about the presently installed client and server versions.



docker --version:
This command returns the version of Docker that is presently installed.



docker pull:
This command retrieves images from the Docker repository.


docker run: 
This command generates a container from an image.


docker ps:
This command displays a list of the currently active containers.


docker ps -a:
This command displays all of the containers (running +exited).


docker exec:
This command is used to gain access to the currently executing container.



docker stop:
This command is used to terminate a running container.


docker kill:
This command terminates the container's execution instantly.


docker images:
This command displays a list of all local Docker images.


docker rmi:
This command deletes an image from local storage.



Stay tuned for further information! Read more about SQL joins and getting started with Docker.

Conclusion

In this post, we learned about virtualization, Virtual Machine, Container, and Docker versions, as well as the installation and use of Docker commands for Windows, Linux, and Mac OS X.

Continue reading to learn about the most recent updates and methods for learning Docker commands that every developer should be familiar with.

  1. SQL Joins
  2. Get Started with Docker

Chandra Sekhar

A Blogger and Author! This post was written and edited by me, a technologist. I started this site to share my inspirations, work, and free materials, which I hope others may find useful as well. Man with a creative streak who enjoys experimenting with various web design strategies.

Previous Post Next Post

Microservice Communication in a Distributed System