4. Why we are learning Docker ?
1. Docker gives you virtual OS Environment.
2. MicroService App runs on Isolated Environment
3. Deliver the application faster.
No need worry about "Production/Test release failures"
Now you can't say
"Hey its working on my Local but not sure why its not working on production/test server :)".
4. Docker gives you a guaranteed same development environment on all 3 phase
1. Development
2. Testing
3. Production
5. Who should learn Docker
● Developers
● DevOps Engineer
● Linux System Administrators
● Data Scientist
10. Docker Architecture
Docker Architecture Consist of 3 Components
1. Docker Client ( Tool/Software that you install on your machine)
2. Docker Daemon ( Service that run inside your machine as background service)
3. Docker Registry (Website/Cloud App)
15. Practical Lab Assignment
1. We will Create a Docker Hub Account
2. Download the image
3. Build Container from image
4. Run the Container
6. Go inside the container
7. Exit from container
8. Stop the Container/ Re Run it
9. Upload the image to docker hub.
9.1 Public Mode
9.2 Private Mode
10. Student will download my Docker Hub image onto their machine
21. DOCKER COMMANDS
Run the Container
Syntax
docker run <flags> <containerName> <shell>
Example
docker run -dp 80:80 myimage
-d = -d flag to run the container in detached mode (background service)
-p = -p flag is used to open the port of application
22. DOCKER COMMANDS
Go inside the container
Syntax
docker exec <flag> <containerId> <shell>
Example
docker exec -it #283aas9878a /bin/bash
-i = --interactive or -i flag to indicate that the container’s STDIN should be opened.
-t = -t flag to allocate a psuedo-TTY to be able to run interactive commands
25. Copy a file from the host to a container
Syntax
docker cp TARGET CONTAINER:SOURCE
Example
docker cp index.html web:/index.html
26. Copy a file from a container to the host
Syntax
docker cp CONTAINER:SOURCE TARGET
Example
docker cp web:/index.html index.html
27. It's hard to start with fresh OS images
Better to use Technology Specific Images
Suppose if you are a Node Js Developer better to start with node image instead of
using ubuntu and install node in the image.
Will be waste of our time . So we will use
docker pull node:latest
Suppose you are a Python Developer the your will use
docker pull python:latest
31. Build Your Own Image/Container
You can build your own container/image using a “Dockerfile”
Syntax
docker image build -t ImageName:TagName dir
or
docker build -t ImageName:TagName dir
Example
docker build -t myimage:1.0.0 .
Docker - File
32.
33. Dockerfile Sample (NodeJS)
FROM node
WORKDIR /var/www/rtc_app
COPY . .
RUN npm install
EXPOSE 5000
CMD ["node","backend/server.js"]
34. Dockerfile Sample (Python)
FROM python:latest
WORKDIR /home
COPY . .
RUN python -m pip install -r requirements.txt
EXPOSE 8000
RUN django-admin startproject anil .
CMD [ "python","manage.py","runserver","0.0.0.0:8000" ]
35. Biggest problem for us now.
"I want to work in host OS but wanted to
see the changes in running container"
The Next Topic "Volume/Mounting" will
give this answer
37. There are 2 Ways
1. Using Command line
2. Using Docker compose file
38. Note
You can't mount a VOLUME in a Dockerfile specifying both source (host)
and destination (container) paths.
This is because this idea does not fit the basic concept that Docker image is
portable and independent of host.
42. By default containers are isolated, means all
ports are closed, so container can not talk to
each other
But ….Some way by which container can talk to
each other.
43. There are 2 Ways
1. Expose the port of container, and allow containers to talk
to each other with host OS. ( Not Recommended )
2. Put the containers inside one network. ( Recommended )
45. 1. Docker compose is a tool which read a docker-compose.yml file.
2. Build the container according to the commands/instructions
provided in the file.
Docker compose ( Installation not required on windows)
Docker compose ( Installation is required on linux )
54. Database
# DB Name DB Type DB GUI PORT
Links
1 MongoDB NoSQL
MongoDB
Compass
27017
https://www.mongodb.com/try/
download/compass
2 Redis DB NoSQL Redis Insight 6379
https://redis.com/redis-enterpri
se/redis-insight/
3 MySQL SQL Workbench 3306
https://dev.mysql.com/downlo
ads/workbench/
4 PostGres SQL PgAdmin 5432
https://www.pgadmin.org/dow
nload/
55. Docker Assignment
NoSQL DBs
Download mongo image and implement the nodejs / python code.
Download redis image and implement the nodejs/python code.
SQL DBs
Download mysql image and implement the nodejs / python code.
Download postgres image and implement the nodejs / python code.
57. Remember
Stop the database services in Host Machine
Solution for windows :
1. Stop docker container
2. win + r and type services.msc
3. Find postgres/mongo services and stop
4. Start your container again
58. Notes
By default containers are isolated, means all ports are closed.
We can open the port in 3 Ways
1. using EXPOSE command in Dockerfile.
2. Using --expose flag in docker run command.
3. Using docker-compose
So external service can talk to container and vice versa.
docker run = docker pull + docker create + docker start
nodemon -L <script_file>
docker logs -f <container_name>
59. Q & A
How to check which containers are running ? docker ps
Write down any 5 Dockerfile commands?
Which is the first Dockerfile command ? FROM
What is the command to stop all running container ? docker stop $(docker ps -q)
What is the command to stop all container ? docker stop $(docker ps -a -q)
What is the command to remove all containers ? docker rm $(docker ps -a -q)
What is the command to remove the image? docker rmi imagename/imageId
61. Do you what to learn Software Development ?
I have 10 Yrs of Teaching and Software industry Experience.
Your can contact me on whatsApp +91-7999452711 or anildalar8888@gmail.com.
I teach my students across the globe.
Classes are daily basis Monday to Saturday 2 Hr Daily,
Daily Assignment, Daily Quiz, Daily Practice .
After the Training you will get Training and Experience Certifications form OKLABS
and DOLLORINFOTECH respectively .
100% placement after the training..
63. GIT, HTML5,CSS3,BootStrap,JS,JQuery, ReactJS ,NodeJS,ExpressJS,
MongoDB,MySQL,Redis,PostGres (All Dbs SQL n NoSQL), Docker,NgRok
Live Project Deployment
Placement IN MNC
Certificates
1. OKLABS Training Certificate (1 Year)
1. DOLLOR INFOTECH Experience Certificate (1 Year)
64. FullStack 1K USD
Student Can Pay in 3 EMI
333USD x 3
In order to enroll You Must pay 1 EMI
All Videos will be Private VIdeos.
1. Daily Class (Monday to Saturday 8:30 AM IST - 9:30 AM IST)
2. Daily Assignment
3. Daily Quiz
4. You will be added into the WhatSAPP Group for Discussion
5. You can Call for Doubts and have anydesk session for discussion