Let’s talk about Docker. As you have read in earlier blogs, What exactly docker is?
Now let’s talk about the next question, What makes Docker so attractive & how does it work ??
Around 10 Years ago, when the virtual machines started, we realized that virtual machines shared the same hardware with the base machine, and while testing if the virtualized machine goes down then it doesn’t affect our host machine, that was the motto of creating a virtualized machine and there are lots of applications which needs their own environment to run.
In short, a virtual machine is a resource through which we can create an elusion for the app that has its own environment. But even at that time base machine had an enormous load of various virtualized machines, to overcome this situation a new application has been launched named ‘docker’.
It is a very lightweight application and shared the kernel with the base machine in other words it virtualized the environment rather than virtualizing a machine.
The main thing I would like to share with you is we have to install the Docker application and then we can run 10-15 containers or more than that on the single base machine without any problem.
Like in our Laptop, we cant install 10-15 virtual machines as various applications need their own environment. So, on your laptop, if there is docker installed, then you can work very easily anywhere around the world. It does not have any dependency issues.
One more thing which is important to know is Docker containers can use their own ports you have two containers and both containers are having apache2 application on port 80, so you can run both containers of apache on different ports at any time.
Docker is very helpful to create an isolated environment.
[DOCKER IN DOCKER’s TERM…]
BUILD ONCE, CONFIGURE ONCE & RUN ANYWHERE……..
There is also one more component in docker DOCKER INDEX….
You must be thinking about what the Docker index is.
Let’s talk about the docker index, it is basically a git repository that contains docker containers and all. You can push containers in that repository or pull containers just like git.
These all points make Docker so attractive….
Now let’s talk about how does docker work?
Let me tell you one thing Docker’s commands are too simple and user-friendly. You only just need to understand the flow of its commands.
ok, let’s install docker in your ubuntu os machine….
First, open the terminal and go to the root user by typing:
1 |
sudo -s |
then update your system by typing:
1 |
apt-get update |
Now check curl if it is not installed then type:
1 |
apt-get install curl |
Get the latest Docker package with the mentioned command:
1 |
curl -sSL https://get.docker.com/ | sh |
now verify whether the Docker is installed or not, type:
1 |
docker --version |
docker version should be 20.10.22.
[Note: you can get lots of ways to install docker in just a few commands but to install an updated version, follow the procedure.]
Now let’s learn how to run docker…..
First, you have to download the docker’s image like I want to download the ubuntu-20.04 image then download it by typing:
1 |
docker pull ubuntu:20.04 |
it will pull the image from the docker hub
After pulling it, you can list the images by typing:
1 |
docker images |
it will show you the complete downloaded images which you have in your system
after that just hit the command to use docker’s image:
1 |
docker run -i -t ubuntu:20.04 |
that command will give you a terminal and then you can run or install whatever you want, but remember after installation if you want to save the changes, you will have to commit the container and for this, you have to open another terminal & from the root user type:
1 |
docker commit your_container_id your_container-name |
now the question arises how do we get to know the container’s id & container’s name?
you can check your container’s id and name by typing:
1 |
docker ps |
after committing it, your container is ready to use.
[ Note: Remember one thing that without committing your container don’t exit from it & run another one otherwise you’ll lose everything that you have worked in it and next time when you will run it, you will get a fresh copy of your previous container, so docker commit is must to save your work in the container” ]
now if you want to run your container in daemonize mode then you have to hit the command:
1 |
docker run -i -d container_name |
To stop running the container:
1 |
docker stop container_id |
To remove the container:
1 |
docker rm container-id |
All basic commands are:
1 |
attach:-Attach to a running containerit |
build:-Build a container from a Dockerfile
commit:-Create a new image from a container’s changes
cp:-Copy files/folders from the container’s filesystem to the host path
diff:-Inspect changes on a container’s filesystem
events:-Get real-time events from the server
export:-Stream the contents of a container as a tar archive
history:-Show the history of an image
images:-List images
import:-Create a new filesystem image from the contents of a tarball
info:-Display system-wide information
insert:-Insert a file in an image
inspect:-Return low-level information on a container
kill:-Kill a running container
load:-Load an image from a tar archive
login:-Register or Login to the docker registry server
logs:-Fetch the logs of a container
port:-Lookup the public-facing port which is NAT-ed to PRIVATE_PORT
ps:-List containers
pull:-Pull an image or a repository from the docker registry server
push:-Push an image or a repository to the docker registry server
restart:-Restart a running container
rm:-Remove one or more containers
rmi:-Remove one or more images
run:-Run a command in a new container
save:-Save an image to a tar archive
search:-Search for an image in the docker index
start:-Start a stopped container
stop:-Stop a running container
tag:-Tag an image into a repository
top:-Lookup the running processes of a container
version:-Show the docker version information
wait:-Block until a container stops, then print its exit code
For Magento 2 Elastic search, please follow the –
Our Cloudkul Blogs
Elasticsearch, Fluentd, and Kibana (EFK)
Setting up Elasticsearch, Logstash, and Kibana for centralized logging
Managing and Monitoring Magento 2 logs with Kibana
Our store modules –
You may also visit our Magento development services and quality Magento 2 Extensions.
For further help or query, please contact us or raise a ticket.
Be the first to comment.