3.4 KiB
3.4 KiB
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
- Windows 11
- **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-appcontainer - 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:
- Bring up the services, force a rebuild of all services, and do not use the cache:
docker-compose up --build --no-cache - Start Containers in Detached Mode: This will run the containers in the background (detached mode):
docker-compose up -d - Stop and Remove Containers: Stops and removes the containers gracefully:
docker-compose down - Stop containers without removing them:
docker-compose stop - Remove Containers, Volumes, and Networks:
docker-compose down --volumes - Force rebuild of containers:
docker-compose build --no-cache - View running Containers:
docker-compose ps - View a specific containers logs:
docker-compose logs <container-name> - Scale services (multiple instances of a service):
docker-compose up --scale <container-name>=<instances number> -d - Watch a specific containers logs in realtime with timestamps:
docker-compose logs -f --timestamps <container-name>
Volume Management Commands
- List Docker volumes:
docker volume ls - Remove Unused volumes
docker volume prune - Remove specific volumes
docker volume rm <volume-name> - Inspect a volume:
docker volume inspect <volume-name>
Container Image Management Commands:
- List running containers:
docker ps - List all containers:
docker os -a - Remove Stopped containers:
docker container prune - Remove a specific container:
docker container rm <container-name> - Remove a specific image:
docker rmi <image-name>:<version> - Remove all unused images:
docker image prune -a
Network Management Commands:
- List networks:
docker network ls - Inspect a specific network:
docker network inspect <network-name> - Remove a specific network:
docker network rm <network-name> - Remove unused networks:
docker network prune
Debugging and maintenance:
- Enter a Running container:
docker exec -it <container name> /bin/bash(could also be/bin/shor for exampleredis-clion a redis node) - View container resource usage:
docker stats - Check Disk space used by Docker:
docker system df - Remove all unused Data (Nuclear option):
docker system prune
Specific examples
- To simulate a Clean state, one should run
docker system prunefollowed bydocker volume prune -a - You can run
docker-compose upwithout the-doption, 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