From 1b8e2eb5b99e9ba8e5104d37e2424e5dbb5928c6 Mon Sep 17 00:00:00 2001 From: ganome Date: Wed, 13 Nov 2024 12:13:22 -0700 Subject: [PATCH] Cleaned up code blocks --- ...rchestration (Kubernetes, Docker Swarm).md | 24 +++------- .../Kernel Virtualization (KVM).md | 4 +- .../Linux Containers LXC.md | 15 ++---- .../Working With Dockerfiles and Images.md | 47 +++++-------------- 4 files changed, 24 insertions(+), 66 deletions(-) diff --git a/10 - Containers and Vitrualization/Container Orchestration (Kubernetes, Docker Swarm).md b/10 - Containers and Vitrualization/Container Orchestration (Kubernetes, Docker Swarm).md index 2d85563..572f5f3 100644 --- a/10 - Containers and Vitrualization/Container Orchestration (Kubernetes, Docker Swarm).md +++ b/10 - Containers and Vitrualization/Container Orchestration (Kubernetes, Docker Swarm).md @@ -113,34 +113,22 @@ Basic steps: 1. Install kubectl (Kubernetes command-line tool) 2. Set up a Kubernetes cluster (e.g., using Minikube for local development) 3. Deploy an application: - ``` - kubectl create deployment my-app --image=my-app-image - ``` + `kubectl create deployment my-app --image=my-app-image` 4. Expose the deployment: - ``` - kubectl expose deployment my-app --type=LoadBalancer --port=8080 - ``` + `kubectl expose deployment my-app --type=LoadBalancer --port=8080` 5. Scale the deployment: - ``` - kubectl scale deployment my-app --replicas=3 - ``` + `kubectl scale deployment my-app --replicas=3` ## 6. Setting Up and Using Docker Swarm Basic steps: 1. Initialize a swarm: - ``` - docker swarm init - ``` + `docker swarm init` 2. Join worker nodes to the swarm 3. Deploy a service: - ``` - docker service create --name my-service my-image - ``` + `docker service create --name my-service my-image` 4. Scale the service: - ``` - docker service scale my-service=3 - ``` + `docker service scale my-service=3` ## 7. Best Practices for Container Orchestration diff --git a/10 - Containers and Vitrualization/Kernel Virtualization (KVM).md b/10 - Containers and Vitrualization/Kernel Virtualization (KVM).md index 83320d9..e978ace 100644 --- a/10 - Containers and Vitrualization/Kernel Virtualization (KVM).md +++ b/10 - Containers and Vitrualization/Kernel Virtualization (KVM).md @@ -30,9 +30,7 @@ c) QEMU for hardware emulation. On most Linux distributions, you can install KVM using the package manager: -```bash -sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils -``` +`sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils` ## 6. Creating and Managing VMs diff --git a/10 - Containers and Vitrualization/Linux Containers LXC.md b/10 - Containers and Vitrualization/Linux Containers LXC.md index 463989b..8cdd11e 100644 --- a/10 - Containers and Vitrualization/Linux Containers LXC.md +++ b/10 - Containers and Vitrualization/Linux Containers LXC.md @@ -13,17 +13,12 @@ LXC uses Linux kernel features such as cgroups, namespaces, and chroot to create ## 3. Installation To install LXC on most Linux distributions: -``` -sudo apt-get update -sudo apt-get install lxc lxc-templates -``` +`sudo apt-get update && sudo apt-get install lxc lxc-templates` ## 4. Creating containers To create a new container: -``` -sudo lxc-create -n mycontainer -t download -- -d ubuntu -r focal -a amd64 -``` +`sudo lxc-create -n mycontainer -t download -- -d ubuntu -r focal -a amd64` This creates a container named "mycontainer" using the Ubuntu Focal (20.04) template for amd64 architecture. @@ -62,9 +57,9 @@ LXC supports multiple storage backends: - Use AppArmor or SELinux profiles ## 10. Advanced features - - Snapshots: Create point-in-time copies of containers - - Live migration: Move running containers between hosts - - Nesting: Run LXC containers inside other LXC containers + - Snapshots: Create point-in-time copies of containers + - Live migration: Move running containers between hosts + - Nesting: Run LXC containers inside other LXC containers ## 11. LXC vs. Docker While both use Linux containerization, they have different focuses: diff --git a/10 - Containers and Vitrualization/Working With Dockerfiles and Images.md b/10 - Containers and Vitrualization/Working With Dockerfiles and Images.md index 71ae2a4..e40dd7b 100644 --- a/10 - Containers and Vitrualization/Working With Dockerfiles and Images.md +++ b/10 - Containers and Vitrualization/Working With Dockerfiles and Images.md @@ -37,40 +37,28 @@ CMD ["python", "app.py"] To build an image from a Dockerfile: -``` -docker build -t myapp:v1 . -``` +`docker build -t myapp:v1 .` This command builds an image named "myapp" with the tag "v1" using the Dockerfile in the current directory. ## 4. Managing Docker Images List images: -``` -docker images -``` +`docker images` Remove an image: -``` -docker rmi myapp:v1 -``` +`docker rmi myapp:v1` Tag an image: -``` -docker tag myapp:v1 myapp:latest -``` +`docker tag myapp:v1 myapp:latest` ## 5. Pushing and Pulling Images Push an image to a registry: -``` -docker push username/myapp:v1 -``` +`docker push username/myapp:v1` Pull an image from a registry: -``` -docker pull username/myapp:v1 -``` +`docker pull username/myapp:v1` ## 6. Multi-stage Builds @@ -101,14 +89,10 @@ CMD ["myapp"] ## 8. Docker Image Inspection Inspect image details: -``` -docker inspect myapp:v1 -``` +`docker inspect myapp:v1` View image history: -``` -docker history myapp:v1 -``` +`docker history myapp:v1` ## 9. Optimizing Docker Images @@ -125,17 +109,13 @@ docker history myapp:v1 - Azure Container Registry (ACR) To use a private registry, log in first: -``` -docker login myregistry.azurecr.io -``` +`docker login myregistry.azurecr.io` ## 11. Image Scanning and Security Use tools like Docker Scan, Clair, or Trivy to scan images for vulnerabilities: -``` -docker scan myapp:v1 -``` +`docker scan myapp:v1` ## 12. Docker Image Versioning @@ -150,9 +130,6 @@ Always tag your images with a specific version and avoid using only the "latest" Use tools like Hadolint to check your Dockerfile for best practices and potential issues: -``` -hadolint Dockerfile -``` - -This guide covers the essentials of working with Dockerfiles and images. As you become more comfortable with these concepts, you can explore advanced topics like Docker Compose for multi-container applications and Docker Swarm or Kubernetes for container orchestration. +`hadolint Dockerfile` +This guide covers the essentials of working with Dockerfiles and images. As you become more comfortable with these concepts, you can explore advanced topics like Docker Compose for multi-container applications and Docker Swarm or Kubernetes for container orchestration. \ No newline at end of file