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)
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

View File

@ -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

View File

@ -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:

View File

@ -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.