-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 20i-0497-Ahmed-Mudassar
- Loading branch information
Showing
13 changed files
with
158 additions
and
1 deletion.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Q1 Docker Containers Vs Vms | ||
Docker containers and virtual machines (VMs) are both technologies used for virtualization, but they operate at different levels of abstraction. VMs virtualize the entire hardware stack, allowing multiple operating systems to run on a single physical machine. Each VM includes its own guest OS, consuming more resources and requiring a hypervisor for management. In contrast, Docker containers share the host OS kernel, making them lightweight and efficient. They encapsulate applications and their dependencies, ensuring consistency across different environments. This makes containers faster to start, use fewer resources, and allows for easier scaling. Overall, Docker containers are well-suited for application deployment and microservices architectures, while VMs are better suited for running multiple, diverse applications on the same host. | ||
|
||
# Q2 Write command to create a docker container in detached mode with name assignment-2-<ROLL_NUMBER> running on host port 9090 and container port 80 using image nginx with version 1.24.0 on a custom network named assignment-2 | ||
|
||
```bash | ||
sudo docker network create assignment-2 | ||
sudo docker pull nginx:1.24.0 | ||
sudo docker run -d -p 9090:80 --network assignment-2 --name assignment-2-I18-0530 nginx:1.24.0 | ||
``` | ||
|
||
# Q3 Share the logs of the command | ||
```bash | ||
vacaramin@vacaramin-Latitude-E7270:~/Desktop/temp/first-contributions$ sudo docker network create assignment-2 | ||
9d393989cd62a77bef164b9be0a59eee079e1cf0ee0a63a07c1181eede144270 | ||
vacaramin@vacaramin-Latitude-E7270:~/Desktop/temp/first-contributions$ sudo docker pull nginx:1.24.0 | ||
1.24.0: Pulling from library/nginx | ||
Digest: sha256:73341830a31bf12a44c846b6b323dd8a4fab7668e72c16e9124913ff097c9536 | ||
Status: Image is up to date for nginx:1.24.0 | ||
docker.io/library/nginx:1.24.0 | ||
vacaramin@vacaramin-Latitude-E7270:~/Desktop/temp/first-contributions$ sudo docker run -d -p 9090:80 --network assignment-2 --name assignment-2-I18-0530 nginx:1.24.0 | ||
3f2872468b2393d15a6dcf78e4805d617ca68e5b86cbf0053fe7a41c1646f9f8 | ||
``` | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Answer1: | ||
Virtual machines: create a complete virtualized environment for each application, including a separate operating system, kernel, and hardware resources. This makes VMs very isolated and secure, but it also makes them more resource-intensive and slower to start up. | ||
|
||
Docker containers: share the host operating system kernel and resources, but each container has its own isolated file system, processes, and network capabilities. This makes containers much more lightweight and faster to start up than VMs, but it also means that they are not as isolated or secure. | ||
|
||
Answer2: | ||
docker run -d --name assignment-2-I19-1746 --network assignment-2 -p 9090:80 nginx:1.24.0 | ||
|
||
Answer 3: | ||
Coomand: | ||
![Screenshot from 2023-10-08 19-46-56](https:/kahootali/first-contributions/assets/115140827/c9f347b2-50e2-408e-90ef-c44dc8a66a06) | ||
|
||
|
||
Logs: | ||
![Screenshot from 2023-10-08 19-48-08](https:/kahootali/first-contributions/assets/115140827/59e28a26-17a7-4616-a1b1-bd75f52cf39c) | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
(Q1) | ||
In VM, there is a hardware level virtualization whereas in Containers there is an Operating System level virtualization. | ||
VMs take more space upto Gigabytes while Containers take less space upto Megabytes. | ||
In VMs, there is static compute, static memory and high resource usage while in Containers there is a burstable compute, burstable memory and low resource usage. | ||
|
||
(Q2) | ||
|
||
Command: | ||
|
||
docker run -d --publish 9090:80 --net assignment-2 --name assignment-2-I19-0743 nginx:1.24.0 | ||
|
||
Output: | ||
|
||
Unable to find image 'nginx:1.24.0' locally | ||
1.24.0: Pulling from library/nginx | ||
7dbc1adf280e: Pull complete | ||
a7184f3665ed: Pull complete | ||
f144d5d97503: Pull complete | ||
9097eea98b48: Pull complete | ||
356d4b647b64: Pull complete | ||
608e661a622a: Pull complete | ||
Digest: sha256:73341830a31bf12a44c846b6b323dd8a4fab7668e72c16e9124913ff097c9536 | ||
Status: Downloaded newer image for nginx:1.24.0 | ||
240e71e4966853fbd777c57ce82bba09cf106638f2bde7291f7f202b7a70c1a8 | ||
|
||
(Q3) | ||
|
||
Command: | ||
|
||
docker container logs assignment-2-I19-0743 | ||
|
||
Output: | ||
|
||
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration | ||
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/ | ||
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh | ||
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf | ||
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf | ||
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh | ||
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh | ||
/docker-entrypoint.sh: Configuration complete; ready for start up | ||
2023/10/07 16:16:01 [notice] 1#1: using the "epoll" event method | ||
2023/10/07 16:16:01 [notice] 1#1: nginx/1.24.0 | ||
2023/10/07 16:16:01 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) | ||
2023/10/07 16:16:01 [notice] 1#1: OS: Linux 6.2.0-34-generic | ||
2023/10/07 16:16:01 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576 | ||
2023/10/07 16:16:01 [notice] 1#1: start worker processes | ||
2023/10/07 16:16:01 [notice] 1#1: start worker process 29 | ||
2023/10/07 16:16:01 [notice] 1#1: start worker process 30 | ||
2023/10/07 16:16:01 [notice] 1#1: start worker process 31 | ||
2023/10/07 16:16:01 [notice] 1#1: start worker process 32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Answers for Questions in Assignment#2 | ||
|
||
# Q1 | ||
- In virtual machines the virtualization is hardware based therefore having its own kernel and OS whereas in Containers OS level virtualization takes place allowing it to share Host kernel. | ||
- In virtual machines libraries and dependancies have to be installed seperately whereas in Containers they come pre-installed. | ||
- Virtual Machines have static compute and memory whereas Containers have burstable compute and memory. | ||
- Virtual Machines are isolated themself not their applications whilst in Containers both the container itself and their respective applications are isolated. | ||
|
||
# Q2 | ||
- "docker network create assignment-2" used for creating a network named assignment-2 | ||
- "docker run -d --name assignment-2-I20-0792 -p 9090:80 --network assignment-2 nginx:1.24.0" used to run container | ||
where: | ||
-d: Runs the container in detached mode, meaning it runs in the background. | ||
--name assignment-2-I20-0792: Specifies the name of the container. | ||
-p 9090:80: Maps port 9090 on the host to port 80 on the container. | ||
--network assignment-2: Connects the container to the custom network named assignment-2. | ||
nginx:1.24.0: Specifies the image to use nginx version 1.24.0. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Question#1: | ||
Explain Docker Containers vs VMs. | ||
|
||
VMs Containers | ||
VMs provide Hardware level virtualization. While Containers provide OS level virtualization. | ||
VMs are more secure Containeres are less secure | ||
They offer static compute and static Memory They offer Burstable compute and burstable memory | ||
Ops have to create VMs and install Software dependencies While Ops only create VMs and install Docker only | ||
along with softwares | ||
VMs have work on my machine issue No work on my machine issue | ||
|
||
|
||
Question#2: | ||
Command to create a Docker container in detached mode | ||
docker run -d --name assignment-2-<I200861> -p 9090:80 --network assignment-2 nginx:1.24.0 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Q1) Explain Docker Containers vs VMs: | ||
|
||
Docker Containers and Virtual Machines (VMs) are both technologies used | ||
for running applications in isolated environments, but they operate differently: | ||
|
||
Docker Containers: | ||
|
||
Containers are lightweight and share the host OS kernel. | ||
They package an application and its dependencies together. | ||
Containers start quickly and use fewer resources. | ||
Ideal for microservices architecture and scaling applications. | ||
|
||
VMs (Virtual Machines): | ||
|
||
VMs are more like running a full operating system. | ||
They run multiple applications on top of a hypervisor. | ||
VMs are slower to start and use more resources. | ||
Suitable for running different OS types and legacy applications. | ||
|
||
Q2) Write command to create a docker container in detached mode with name assignment-2-<ROLL_NUMBER> | ||
running on host port 9090 and container port 80 using image nginx with version | ||
1.24.0 on a custom network named assignment-2: | ||
|
||
docker run -d --name assignment-2-i20-0538 -p 9090:80 --network assignment-2 nginx:1.24.0 | ||
|
||
![Screenshot](https://imgur.com/a/gsopNEa) | ||
|
||
|
||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Submodule first-contribution
deleted from
67db8a