diff --git a/_reference/dockerreadme.md b/_reference/dockerreadme.md index a7f8e2aef..b65c6b23d 100644 --- a/_reference/dockerreadme.md +++ b/_reference/dockerreadme.md @@ -109,7 +109,9 @@ To ensure the changes are fully applied, restart WSL2: 2. Test Access from other Devices: - If you're running services inside WSL (e.g., a web server), ensure they are accessible from other devices on your local network using the static IP address you configured (e.g., `http://192.168.1.100:4000`). -## Step 6: Configuring `vm.overcommit_memory` in sysctl for WSL2 + + +# Configuring `vm.overcommit_memory` in sysctl for WSL2 To prevent memory overcommitment issues and optimize performance, you can configure the `vm.overcommit_memory` setting in WSL2. This is particularly useful when running Redis or other memory-intensive services inside WSL2, as it helps control how the Linux kernel handles memory allocation. @@ -133,3 +135,48 @@ After editing the file, save it and then apply the new sysctl configuration by r sudo sysctl -p ``` +# Install Docker and Docker Compose in WSL2 +- https://docs.docker.com/desktop/wsl/ + +# Docker Commands + +## General `docker-compose` Commands: +1. Bring up the services, force a rebuild of all services, and do not use the cache: `docker-compose up --build --no-cache` +2. Start Containers in Detached Mode: This will run the containers in the background (detached mode): `docker-compose up -d` +3. Stop and Remove Containers: Stops and removes the containers gracefully: `docker-compose down` +4. Stop containers without removing them: `docker-compose stop` +5. Remove Containers, Volumes, and Networks: `docker-compose down --volumes` +6. Force rebuild of containers: `docker-compose build --no-cache` +7. View running Containers: `docker-compose ps` +8. View a specific containers logs: `docker-compose logs ` +9. Scale services (multiple instances of a service): `docker-compose up --scale = -d` + +## Volume Management Commands +1. List Docker volumes: `docker volume ls` +2. Remove Unused volumes `docker volume prune` +3. Remove specific volumes `docker volume rm ` +4. Inspect a volume: `docker volume inspect ` + +## Container Image Management Commands: +1. List running containers: `docker ps` +2. List all containers: `docker os -a` +3. Remove Stopped containers: `docker container prune` +4. Remove a specific container: `docker container rm ` +5. Remove a specific image: `docker rmi :` +6. Remove all unused images: `docker image prune -a` + +## Network Management Commands: +1. List networks: `docker network ls` +2. Inspect a specific network: `docker network inspect ` +3. Remove a specific network: `docker network rm ` +4. Remove unused networks: `docker network prune` + +## Debugging and maintenance: +1. Enter a Running container: `docker exec -it /bin/bash` (could also be `/bin/sh` or for example `redis-cli` on a redis node) +2. View container resource usage: `docker stats` +3. Check Disk space used by Docker: `docker system df` +4. Remove all unused Data (Nuclear option): `docker system prune` + +## Specific examples +1. To simulate a Clean state, one should run `docker system prune` followed by `docker volume prune -a` +2. You can run `docker-compose up` without the `-d` option, and you will get what is identical to the experience you were used to, this includes being able to control-c and bring the entire stack down diff --git a/docker-compose.yml b/docker-compose.yml index 054de22ab..4e8ecf9d4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,8 +15,8 @@ services: networks: - redis-cluster-net volumes: - - ./redis/dockerdata/redis-node-1:/data - - ./redis/dockerdata/lock:/redis-lock + - redis-node-1-data:/data + - redis-lock:/redis-lock healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s @@ -32,8 +32,8 @@ services: networks: - redis-cluster-net volumes: - - ./redis/dockerdata/redis-node-2:/data - - ./redis/dockerdata/lock:/redis-lock + - redis-node-2-data:/data + - redis-lock:/redis-lock healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s @@ -49,8 +49,8 @@ services: networks: - redis-cluster-net volumes: - - ./redis/dockerdata/redis-node-3:/data - - ./redis/dockerdata/lock:/redis-lock + - redis-node-3-data:/data + - redis-lock:/redis-lock healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s @@ -96,7 +96,16 @@ services: - "3334:5540" networks: - redis-cluster-net + volumes: + - redis-insight-data:/db networks: redis-cluster-net: driver: bridge + +volumes: + redis-node-1-data: + redis-node-2-data: + redis-node-3-data: + redis-lock: + redis-insight-data: diff --git a/redis/dockerdata/.gitignore b/redis/dockerdata/.gitignore deleted file mode 100644 index d65193fa1..000000000 --- a/redis/dockerdata/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -* -!lock/ -lock/* -!lock/.gitkeep diff --git a/redis/dockerdata/lock/.gitkeep b/redis/dockerdata/lock/.gitkeep deleted file mode 100644 index e69de29bb..000000000