Hello Everyone , Today we'll talk about what is docker ?, how to use it ? and why you should use it ?,
then let's begin...
What is Docker ?
- According to Wikipeadia " Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers.".
- Docker provides platform for building project easily. it has images of what you want (like database or OS) and you can perform task on that container and build project with it.
Didn't Get completely ?
it works on my pc then why not on my friend's pc.
So Docker is solution of this problem.
How it works and why it is Better than Virtual Machine ?
- It is Faster and better than VM because when you install image of OS then it won't be downloading kernel for it , docker will use main kernel as new OS's kernel too. but you can not use this on different kernel based system (like ubuntu can not be used in window)
- so it just became faster than VM because it use one layer which is of Application. see below image to understand more about it.
How to use Docker ?
- First install Docker , Installation Steps
- Go to docker hub and search for any image you want to use
i will be using mysql for demo purpose ,
type,
docker run mysql
(it will download and run automatically)
still won't run until you set root password for mysql
now type
docker run --name mysql_db -d -p 3300:3306 -e MYSQL_ROOT_PASSWORD=mypassword mysql:latest
Here , --name assign name to mysql:latest container , -e set up environment variables , -d for detach mode , -p for setting up local-port:docker-port
now check with ,
docker ps
Here, ps shows running docker container and if you add -a then it will show all containers
if there is something named mysql_db is running then that's it mysql is running in docker container .
Now for using mysql in docker type,
docker exec -it mysql_db /bin/bash
Here exec -it will open interactive terminal for mysql
now type,
mysql -u root -p mypassword
now you are done , you can use mysql.
You are using sql but in docker now you can create project using multiple docker images and deploy them to cloud or you can send to anyone.
So that was basic knowledge of docker. still want to know more watch this video
if you want to see project(django+mysql+phpmyadmin) related to docker checkout my github
If you are having any trouble in setting-up docker then comment down , i'll try my best to help you.
Thank You 😊😊
Comments
Post a Comment