A hands-on guide to Dockerizing a Frontend React App.
πΊ Learned from: JavaScript Mastery
- Getting Started
- Building & Running Images
- Working with Volumes
- Managing Containers
- Publishing to Docker Hub
- Docker Compose
docker run -it ubuntuThis pulls the Ubuntu image and runs it in interactive mode.
docker build -t hello-docker .docker imagesdocker run hello-dockerdocker run -it hello-docker shExpose Docker's internal ports to your host system:
docker run -p 5173:5173 react-dockerMount the container to your local codebase for live development:
docker run -p 5173:5173 -v "$(pwd):/app" -v /app/node_modules react-docker| Flag | Description |
|---|---|
-v "$(pwd):/app" |
Mounts current directory to /app in container |
-v /app/node_modules |
Preserves container's node_modules (avoids conflicts) |
π‘ Tip: This is especially useful during development for hot-reloading.
docker psdocker ps -adocker container prunedocker rm <container_id>Force remove a running container:
docker rm <container_id> --forcedocker logindocker tag react-docker developerjunaid/react-dockerdocker push developerjunaid/react-dockerDocker Compose simplifies multi-container workflows using a YAML configuration file.
docker initFollow the interactive prompts to generate Dockerfile and compose.yaml.
docker compose updocker compose up -ddocker compose downdocker-crash-course/
βββ hello-docker/ # Simple Node.js Docker example
βββ react-docker/ # React app with manual Docker setup
βββ react-docker-compose/ # React app with Docker Compose
βββ Readme.md
| Command | Description |
|---|---|
docker build -t <name> . |
Build an image |
docker run <image> |
Run a container |
docker run -p <host>:<container> <image> |
Run with port mapping |
docker ps |
List running containers |
docker images |
List images |
docker rm <id> |
Remove container |
docker rmi <image> |
Remove image |
docker compose up |
Start services from compose.yaml |
docker compose down |
Stop and remove services |
Made with β€οΈ while learning Docker

