Merge pull request #33 from SCAR-iT-COLO/23-sanitize-chapter-10

Cleaned up code blocks
This commit is contained in:
Ganome 2024-11-13 12:14:36 -07:00 committed by GitHub
commit 55f29d96ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 66 deletions

View File

@ -113,34 +113,22 @@ Basic steps:
1. Install kubectl (Kubernetes command-line tool) 1. Install kubectl (Kubernetes command-line tool)
2. Set up a Kubernetes cluster (e.g., using Minikube for local development) 2. Set up a Kubernetes cluster (e.g., using Minikube for local development)
3. Deploy an application: 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: 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: 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 ## 6. Setting Up and Using Docker Swarm
Basic steps: Basic steps:
1. Initialize a swarm: 1. Initialize a swarm:
``` `docker swarm init`
docker swarm init
```
2. Join worker nodes to the swarm 2. Join worker nodes to the swarm
3. Deploy a service: 3. Deploy a service:
``` `docker service create --name my-service my-image`
docker service create --name my-service my-image
```
4. Scale the service: 4. Scale the service:
``` `docker service scale my-service=3`
docker service scale my-service=3
```
## 7. Best Practices for Container Orchestration ## 7. Best Practices for Container Orchestration

View File

@ -30,9 +30,7 @@ c) QEMU for hardware emulation.
On most Linux distributions, you can install KVM using the package manager: 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 ## 6. Creating and Managing VMs

View File

@ -13,17 +13,12 @@ LXC uses Linux kernel features such as cgroups, namespaces, and chroot to create
## 3. Installation ## 3. Installation
To install LXC on most Linux distributions: 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 ## 4. Creating containers
To create a new container: 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. This creates a container named "mycontainer" using the Ubuntu Focal (20.04) template for amd64 architecture.

View File

@ -37,40 +37,28 @@ CMD ["python", "app.py"]
To build an image from a Dockerfile: 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. This command builds an image named "myapp" with the tag "v1" using the Dockerfile in the current directory.
## 4. Managing Docker Images ## 4. Managing Docker Images
List images: List images:
``` `docker images`
docker images
```
Remove an image: Remove an image:
``` `docker rmi myapp:v1`
docker rmi myapp:v1
```
Tag an image: Tag an image:
``` `docker tag myapp:v1 myapp:latest`
docker tag myapp:v1 myapp:latest
```
## 5. Pushing and Pulling Images ## 5. Pushing and Pulling Images
Push an image to a registry: Push an image to a registry:
``` `docker push username/myapp:v1`
docker push username/myapp:v1
```
Pull an image from a registry: Pull an image from a registry:
``` `docker pull username/myapp:v1`
docker pull username/myapp:v1
```
## 6. Multi-stage Builds ## 6. Multi-stage Builds
@ -101,14 +89,10 @@ CMD ["myapp"]
## 8. Docker Image Inspection ## 8. Docker Image Inspection
Inspect image details: Inspect image details:
``` `docker inspect myapp:v1`
docker inspect myapp:v1
```
View image history: View image history:
``` `docker history myapp:v1`
docker history myapp:v1
```
## 9. Optimizing Docker Images ## 9. Optimizing Docker Images
@ -125,17 +109,13 @@ docker history myapp:v1
- Azure Container Registry (ACR) - Azure Container Registry (ACR)
To use a private registry, log in first: To use a private registry, log in first:
``` `docker login myregistry.azurecr.io`
docker login myregistry.azurecr.io
```
## 11. Image Scanning and Security ## 11. Image Scanning and Security
Use tools like Docker Scan, Clair, or Trivy to scan images for vulnerabilities: 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 ## 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: Use tools like Hadolint to check your Dockerfile for best practices and potential issues:
``` `hadolint Dockerfile`
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. 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.