-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDocker.txt
43 lines (39 loc) · 3.38 KB
/
Docker.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
1. What is Docker?
Answer:
Docker is a containerization platform which packages your application and all its dependencies together in the form of containers so as to ensure that your application works seamlessly in any environment be it development or test or production.
Docker containers, wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries etc. anything that can be installed on a server.
This guarantees that the software will always run the same, regardless of its environment.
2. What is the difference between a Docker image and a container?
Answer:
An instance of an image is called a container. You have an image, which is a set of layers. If you start this image, you have a running container of this image.
You can have many running containers of the same image.
You can see all your images with docker images whereas you can see your running containers with docker ps (and you can see all containers with docker ps -a).
3. container VS Virtual machine
VMs are heavy software packages that provide complete emulation of low level hardware devices like CPU, Disk and Networking devices.
VMs may also include a complementary software stack to run on the emulated hardware.
These hardware and software packages combined produce a fully functional snapshot of a computational system
Containers are lightweight software packages that contain all the dependencies required to execute the contained software application.
These dependencies include things like system libraries,
external 3rd party code packages, and other operating system level applications
4. Explain Port mapping in docker
• Publishing Docker ports via -P or -p
• There are two ways of publishing ports in Docker:
• Using the -P flag (Random Port Mapping)
• Using the -p flag (Fixed Port mapping using UDP/TCP)
Fixed Port mapping using UDP/TCP
• when you expose a port from Dockerfile that means you are mapping a port defined in
your image to your newly launched container
#docker run -d -p 8080:80 --name=mycontaniername myimagename
#docker run -d --name MyWebServer -p 8080:80 httpd
• when you want to change the protocol from default i.e tcp to udp , use:
#docker run -d -p 8080:80/udp --name=mycontinername myimagename
#docker run -d --name MyWebServer -p 8080:80/udp httpd
5. Docker networking
bridge: The default network driver. If you don’t specify a driver, this is the type of network you are creating.
Bridge networks are usually used when your applications run in standalone containers that need to communicate. See bridge networks.
host: For standalone containers, remove network isolation between the container and the Docker host, and use the host’s networking directly.
See use the host network.
overlay: Overlay networks connect multiple Docker daemons together and enable swarm services to communicate with each other.
You can also use overlay networks to facilitate communication between a swarm service and a standalone container, or
between two standalone containers on different Docker daemons. This strategy removes the need to do OS-level routing between these containers.
See overlay networks.