Skip to content

Commit 0190eea

Browse files
Merge upstream main into Abhash/Changes
2 parents fb43872 + bc03d65 commit 0190eea

12 files changed

Lines changed: 530 additions & 155 deletions

File tree

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
# No special permissions needed for public repositories
55
GITHUB_TOKEN=your_github_token_here
66

7+
# GitHub token used by Docusaurus for dynamic features (discussions, stats, leaderboard)
8+
# This must be set for the discussions section to fetch live data from GitHub
9+
# Create a Classic PAT with read:discussion scope at https://github.com/settings/tokens
10+
DOCUSAURUS_GIT_TOKEN=your_github_token_here
11+
712
# Shopify Configuration (for Merch Store)
813
# Get these from: Shopify Admin > Settings > Apps and sales channels > Develop apps
914
# Required scopes: unauthenticated_read_product_listings, unauthenticated_write_checkouts

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ yarn-error.log*
2424

2525
# Temporary files
2626
/tmp/
27+
tsconfig.tsbuildinfo

docs/Docker/docker-commands.md

Lines changed: 147 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,73 @@ docker-compose pull
398398

399399
---
400400

401+
## Docker Swarm Commands
402+
403+
Docker Swarm is Docker's native clustering and orchestration tool, allowing you to manage a group of Docker hosts as a single virtual system.
404+
405+
### Swarm Initialization & Node Management
406+
```bash
407+
# Initialize a swarm
408+
docker swarm init --advertise-addr <MANAGER-IP>
409+
410+
# Get the join token for workers
411+
docker swarm join-token worker
412+
413+
# Join a worker node to the swarm
414+
docker swarm join --token <TOKEN> <MANAGER-IP>:2377
415+
416+
# List nodes in the swarm
417+
docker node ls
418+
419+
# Promote a worker to manager
420+
docker node promote <NODE-ID>
421+
422+
# Demote a manager to worker
423+
docker node demote <NODE-ID>
424+
```
425+
426+
### Service Management
427+
```bash
428+
# Create a service
429+
docker service create --name my-service --replicas 3 -p 80:80 nginx
430+
431+
# List services
432+
docker service ls
433+
434+
# List tasks of a service
435+
docker service ps my-service
436+
437+
# Scale a service
438+
docker service scale my-service=5
439+
440+
# Update a service (e.g., image version)
441+
docker service update --image nginx:latest my-service
442+
443+
# Inspect a service
444+
docker service inspect my-service
445+
446+
# Remove a service
447+
docker service rm my-service
448+
```
449+
450+
### Stack Management
451+
Stacks are the swarm equivalent of Docker Compose, used to manage multi-service applications.
452+
```bash
453+
# Deploy a stack from a compose file
454+
docker stack deploy -c docker-compose.yml my-stack
455+
456+
# List stacks
457+
docker stack ls
458+
459+
# List services in a stack
460+
docker stack services my-stack
461+
462+
# Remove a stack
463+
docker stack rm my-stack
464+
```
465+
466+
---
467+
401468
## Advanced Commands
402469

403470
### Container Inspection
@@ -458,18 +525,25 @@ docker run --security-opt no-new-privileges nginx
458525

459526
| Command | Description |
460527
|---------|-------------|
461-
| `docker run` | Create and start container |
528+
| `docker run` | Create and start a container |
462529
| `docker ps` | List running containers |
463530
| `docker images` | List images |
464-
| `docker build` | Build image from Dockerfile |
465-
| `docker pull` | Download image |
466-
| `docker push` | Upload image |
467-
| `docker exec` | Execute command in container |
468-
| `docker logs` | View container logs |
469-
| `docker stop` | Stop container |
470-
| `docker rm` | Remove container |
471-
| `docker rmi` | Remove image |
472-
531+
| `docker build` | Build an image from a Dockerfile |
532+
| `docker pull` | Download an image from a registry |
533+
| `docker push` | Upload an image to a registry |
534+
| `docker exec` | Execute a command inside a running container |
535+
| `docker logs` | View a container's output logs |
536+
| `docker stop` | Stop a running container |
537+
| `docker restart` | Restart a container |
538+
| `docker rm` | Remove a container |
539+
| `docker rmi` | Remove an image |
540+
| `docker inspect` | Show detailed info on a Docker object |
541+
| `docker stats` | Show live resource usage statistics |
542+
| `docker-compose up` | Start a multi-container application |
543+
| `docker network ls` | List all Docker networks |
544+
| `docker volume ls` | List all Docker volumes |
545+
| `docker system prune` | Clean up unused images, containers, and networks |
546+
473547
### Quick Cleanup
474548

475549
```bash
@@ -491,6 +565,62 @@ docker volume prune
491565

492566
---
493567

568+
## Docker Security: Hardening Your Environment
569+
570+
Security is a critical aspect of containerization. Docker provides several built-in mechanisms to secure your applications and infrastructure.
571+
572+
### 1. Secrets Management
573+
Secrets allow you to store sensitive data (like passwords, API keys, or certificates) outside of your images or source code.
574+
```bash
575+
# Create a secret from a file
576+
docker secret create db_password ./password.txt
577+
578+
# List secrets
579+
docker secret ls
580+
581+
# Inspect a secret
582+
docker secret inspect db_password
583+
584+
# Use a secret in a service
585+
docker service create --name db --secret db_password mariadb
586+
```
587+
588+
### 2. Docker Content Trust (DCT)
589+
DCT allows you to use digital signatures for data sent to and received from remote Docker registries. These signatures allow client-side verification of the integrity and publisher of specific image tags.
590+
```bash
591+
# Enable Content Trust (shell session)
592+
export DOCKER_CONTENT_TRUST=1
593+
594+
# Pull only signed images
595+
docker pull nginx:latest
596+
```
597+
598+
### 3. Vulnerability Scanning
599+
Regularly scan your images for known vulnerabilities to ensure your software supply chain is secure.
600+
```bash
601+
# Scan an image for vulnerabilities
602+
docker scan my-image:latest
603+
```
604+
605+
### 4. User Namespaces & Rootless Docker
606+
Running Docker in "Rootless Mode" or using User Namespaces adds a layer of security by ensuring that even if a container is compromised, the attacker does not have root access to the host.
607+
```bash
608+
# Check if rootless mode is supported
609+
docker system info | grep "Rootless"
610+
611+
# Run a container with a specific user namespace
612+
docker run --userns-remap=default -it alpine sh
613+
```
614+
615+
### 5. Resource Isolation
616+
Prevent Denial of Service (DoS) attacks by strictly limiting the resources a container can consume.
617+
```bash
618+
# Limit memory, CPU, and pids (process limit)
619+
docker run -m 512m --cpus="0.5" --pids-limit 100 my-app
620+
```
621+
622+
---
623+
494624
## Best Practices
495625

496626
### Command Tips
@@ -502,21 +632,15 @@ docker volume prune
502632
5. **Use health checks** - Monitor container health
503633
6. **Clean up regularly** - Remove unused objects
504634

505-
### Security Tips
635+
### Security Best Practices
506636

507-
```bash
508-
# Don't run as root
509-
docker run -u 1000:1000 my-app
637+
1. **Don't run as root** - Use the `USER` instruction in Dockerfile or `-u` flag.
638+
2. **Use read-only filesystem** - Prevents attackers from writing to the container disk.
639+
3. **Scan images regularly** - Use `docker scan` to find vulnerabilities.
640+
4. **Use Secrets** - Never bake passwords or keys into your images.
641+
5. **Limit Resources** - Always set memory and CPU limits to prevent host exhaustion.
510642

511-
# Use read-only filesystem when possible
512-
docker run --read-only my-app
513-
514-
# Drop unnecessary capabilities
515-
docker run --cap-drop ALL --cap-add NET_BIND_SERVICE my-app
516-
517-
# Use security profiles
518-
docker run --security-opt apparmor:my-profile my-app
519-
```
643+
Refer to the **Docker Security** section above for more detailed commands and implementation details.
520644

521645
---
522646

docs/Docker/intro.md

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,51 @@ CMD ["node", "app.js"]
5656
### Registry
5757
A storage service for Docker images. **Docker Hub** is the most popular—like GitHub for Docker images.
5858

59-
### Volume
60-
Persistent storage that survives when containers are deleted. Use for databases, logs, and user files.
61-
62-
### Network
59+
### Volumes
60+
Persistent storage that survives when containers are deleted. Essential for databases, logs, and user-generated content.
61+
62+
#### Types of Volumes:
63+
1. **Named Volumes**: Managed by Docker. Best for persistent data like databases.
64+
```bash
65+
# Create a volume
66+
docker volume create pg_data
67+
# Run container with named volume
68+
docker run -d -v pg_data:/var/lib/postgresql/data postgres
69+
```
70+
2. **Bind Mounts**: Maps a host path to a container path. Best for development.
71+
```bash
72+
# Mount current directory to /app
73+
docker run -d -v $(pwd):/app node:18-alpine
74+
```
75+
3. **Tmpfs Mounts**: Stored in host memory (RAM). Best for sensitive or temporary data.
76+
```bash
77+
docker run -d --tmpfs /app/cache my-app
78+
```
79+
80+
### Networks
6381
Allows containers to communicate with each other securely.
6482

83+
#### Network Drivers & Use Cases:
84+
1. **Bridge (Default)**: Best for standalone containers that need to talk to each other on the same host.
85+
- **Use Case**: Connecting a frontend container to a backend container.
86+
```bash
87+
docker network create my-net
88+
docker run -d --net my-net --name db mysql
89+
docker run -d --net my-net --name app my-app
90+
```
91+
2. **Host**: Removes isolation between host and container (shares host IP).
92+
- **Use Case**: High-performance apps where network overhead must be minimal.
93+
```bash
94+
docker run -d --network host nginx
95+
```
96+
3. **Overlay**: Connects multiple Docker daemons together.
97+
- **Use Case**: Microservices spread across multiple physical servers (Docker Swarm).
98+
4. **None**: Disables all networking.
99+
- **Use Case**: Secure batch processing jobs with no external access needed.
100+
```bash
101+
docker run -d --network none alpine
102+
```
103+
65104
## Quick Start Workflow
66105

67106
**1. Create a Dockerfile**
@@ -159,4 +198,4 @@ Docker has revolutionized software development and deployment because:
159198
* **DevOps Integration**
160199
Perfect fit for CI/CD pipelines, enabling automated testing and deployment workflows.
161200

162-
Ready to dive deeper? Let's explore Docker installation and setup in the next section! 🚀
201+
Ready to dive deeper? Let's explore Docker installation and setup in the next section! 🚀

docusaurus.config.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dotenv.config();
99

1010
const config: Config = {
1111
title: "recode hive",
12-
tagline: "Dinosaurs are cool",
12+
tagline: "Learn, Build & Grow with Open Source",
1313
favicon: "img/favicon.ico",
1414

1515
url: "https://www.recodehive.com",
@@ -213,6 +213,24 @@ const config: Config = {
213213
// type: "search",
214214
// position: "right",
215215
// },
216+
{
217+
type: "html",
218+
position: "right",
219+
value: `<a href="https://github.com/recodehive" target="_blank" rel="noopener noreferrer" aria-label="GitHub" title="GitHub" class="navbar__link navbar-social-icon">
220+
<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
221+
<path d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"/>
222+
</svg>
223+
</a>`,
224+
},
225+
{
226+
type: "html",
227+
position: "right",
228+
value: `<a href="https://discord.gg/b6ffxhXRNH" target="_blank" rel="noopener noreferrer" aria-label="Discord" title="Discord" class="navbar__link navbar-social-icon">
229+
<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
230+
<path d="M20.317 4.37a19.791 19.791 0 00-4.885-1.515.074.074 0 00-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 00-5.487 0 12.64 12.64 0 00-.617-1.25.077.077 0 00-.079-.037A19.736 19.736 0 003.677 4.37a.07.07 0 00-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 00.031.057 19.9 19.9 0 005.993 3.03.078.078 0 00.084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 00-.041-.106 13.107 13.107 0 01-1.872-.892.077.077 0 01-.008-.128 10.2 10.2 0 00.372-.292.074.074 0 01.077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 01.078.01c.12.098.246.198.373.292a.077.077 0 01-.006.127 12.299 12.299 0 01-1.873.892.077.077 0 00-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 00.084.028 19.839 19.839 0 006.002-3.03.077.077 0 00.032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 00-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"/>
231+
</svg>
232+
</a>`,
233+
},
216234
{
217235
type: "html",
218236
position: "right",

package-lock.json

Lines changed: 2 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)