65 lines
3.4 KiB
Markdown
65 lines
3.4 KiB
Markdown
# Setting up External Networking and Static IP for WSL2 using Hyper-V
|
|
|
|
This guide will walk you through the steps to configure your WSL2 (Windows Subsystem for Linux) instance to use an external Hyper-V virtual switch, enabling it to connect directly to your local network. Additionally, you'll learn how to assign a static IP address to your WSL2 instance.
|
|
|
|
## Prerequisites
|
|
|
|
1. **Windows 11**
|
|
2. **Docker Desktop For Windows (Latest Version)
|
|
|
|
# Docker Setup
|
|
Inside the root of the project exists the `docker-compose.yaml` file, you can simply run
|
|
`docker-compose up` to launch the backend.
|
|
|
|
Things to note:
|
|
- When installing NPM packages, you will need to rebuild the `node-app` container
|
|
- Making changes to the server files will restart the `node-app`
|
|
|
|
# Local Stack
|
|
- LocalStack Front end (Optional) - https://apps.microsoft.com/detail/9ntrnft9zws2?hl=en-us&gl=US
|
|
- http://localhost:4566/_aws/ses will allow you to see emails sent
|
|
|
|
# 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 <container-name>`
|
|
9. Scale services (multiple instances of a service): `docker-compose up --scale <container-name>=<instances number> -d`
|
|
10. Watch a specific containers logs in realtime with timestamps: `docker-compose logs -f --timestamps <container-name>`
|
|
|
|
## Volume Management Commands
|
|
1. List Docker volumes: `docker volume ls`
|
|
2. Remove Unused volumes `docker volume prune`
|
|
3. Remove specific volumes `docker volume rm <volume-name>`
|
|
4. Inspect a volume: `docker volume inspect <volume-name>`
|
|
|
|
## 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 <container-name>`
|
|
5. Remove a specific image: `docker rmi <image-name>:<version>`
|
|
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 <network-name>`
|
|
3. Remove a specific network: `docker network rm <network-name>`
|
|
4. Remove unused networks: `docker network prune`
|
|
|
|
## Debugging and maintenance:
|
|
1. Enter a Running container: `docker exec -it <container name> /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
|