This Docker setup provides a robust environment for network sniffing activities using Scapy within JupyterLab. Here's a quick overview of the key components:
The Dockerfile builds upon the jupyter/datascience-notebook
image, adding:
libpcap-dev
for packet capture capabilities- Custom Python requirements (scapy)
- A dedicated
/src
working directory
The docker-compose file orchestrates the container:
- Maps various local directories to the container
- Exposes port 8080 for JupyterLab access
- Grants necessary network capabilities (
NET_ADMIN
andNET_RAW
) - Launches JupyterLab without authentication for ease of use
This configuration creates a powerful, isolated environment for network analysis and experimentation with Scapy, all within the familiar JupyterLab interface.
Below the Dockerfile:
FROM jupyter/datascience-notebook:python-3.10
USER root
# Installa libpcap-dev
RUN apt-get update && apt-get install -y libpcap-dev
# Installa le dipendenze
COPY requirements.txt /tmp/
RUN pip install --no-cache-dir -r /tmp/requirements.txt && \
rm /tmp/requirements.txt
# Crea e configura la directory di lavoro
WORKDIR /src
COPY . /src
# Cambia il proprietario della directory di lavoro all'utente jovyan
RUN chown -R jovyan:users /src
# Torna all'utente non-root
USER jovyan
EXPOSE 8080
Below the docker-compose.yml:
version: '3'
services:
jupyterlab:
user: root
restart: always
build:
context: .
dockerfile: Dockerfile
container_name: jupyterlab
working_dir: '/src'
volumes:
- ./src:/src
- ./src/data_lake:/src/data_lake
- ./src/data_lake/input:/src/data_lake/input
- ./src/data_lake/output:/src/data_lake/output
- ./src/notebooks:/src/notebooks
- ./src/modules:/src/modules
- ./src/debug:/src/debug
- ./src/docs:/src/docs
ports:
- '8080:8080'
cap_add:
- NET_ADMIN
- NET_RAW
command: jupyter lab --ip 0.0.0.0 --port=8080 --no-browser --NotebookApp.token='' --allow-root
```