A browser based terminal emulator built as part of a hiring task. Users can launch an isolated Ubuntu Docker container directly from the browser, type commands, and see live output all in real time via WebSockets.
Build a Browser-Based Terminal App where the user opens the browser and clicks a "Launch Lab" button. A Docker container is created for that session. The user can type commands in the browser terminal, which run inside the container β just like Killercoda.
| Layer | Technology |
|---|---|
| Frontend | HTML, CSS, JavaScript |
| Terminal UI | Xterm.js |
| Backend | Python, Django |
| Real-time | Django Channels (WebSocket) |
| Container | Docker (Ubuntu image) |
| Docker Integration | Docker SDK for Python |
| Server | ASGI via Daphne / Uvicorn |
Terminal-project/
βββ README.md
βββ termidock/
βββ manage.py # Django management script
βββ requirements.txt # Python dependencies
βββ static/ # Static files (CSS, JS, assets)
βββ templates/
β βββ index.html # Main frontend β Launch Lab UI + Xterm.js terminal
βββ lab/ # Core Django app β terminal & Docker logic
β βββ __init__.py
β βββ consumers.py # WebSocket consumer β bridges browser β Docker container
β βββ routing.py # WebSocket URL routing
β βββ urls.py # HTTP URL patterns for the lab app
β βββ views.py # HTTP views β serves the frontend page
βββ terminal_lab/ # Django project configuration
βββ __init__.py
βββ asgi.py # ASGI entry point β routes HTTP + WebSocket connections
βββ settings.py # Project settings (Channels, installed apps, etc.)
βββ urls.py # Root URL configuration
Browser (Xterm.js)
|
| WebSocket
β
Django Channels (consumers.py)
|
| Docker SDK for Python
β
Ubuntu Docker Container
- The user opens the app and sees the Ubuntu Labs page (
index.html). - Clicking Launch Lab sends a request to the backend, which uses the Docker SDK to spin up a new Ubuntu container.
- The browser opens a WebSocket connection handled by
lab/consumers.py. - The consumer attaches to the container's shell (exec session), relaying input/output in real time.
- Output from the container streams back to Xterm.js in the browser.
- When the user clicks End Lab (or closes the tab), the consumer stops and removes the container automatically.
- Python 3.12+
- Docker (running locally)
- pip
# Pull the Ubuntu Docker image (first time only)
docker pull ubuntu
# Clone the repository
git clone https://github.com/HashimN225/Terminal-Project.git
cd Terminal-Project/termidock
# Create and activate virtual environment
# Mac and Linux
python3 -m venv myvenv
source myvenv/bin/activate
# Windows
python -m venv myvenv
myvenv\Scripts\activate
# Install Python dependencies
pip install -r requirements.txt
# Run the development server
daphne -b 0.0.0.0 -p 8000 terminal_lab.asgi:application
Then open your browser and go to http://localhost:8000.
- After opening,
http://localhost:8000in your browser. - Click Launch Lab β a Docker container starts and the terminal appears.
- Type any Linux command (e.g.,
ls,pwd,echo hello) and hit Enter. - The command runs inside the container and output appears instantly.
- Click End Lab to stop and remove the container.
- (Optional) Click Reset Lab to restart with a fresh container.
See requirements.txt for the full list of dependencies. Key packages include:
djangoβ Web frameworkchannelsβ WebSocket support via ASGIdockerβ Docker SDK for Pythondaphneβ ASGI server