diff --git a/src/41-xdp-tcpdump/Dockerfile b/src/41-xdp-tcpdump/Dockerfile new file mode 100644 index 0000000..110f430 --- /dev/null +++ b/src/41-xdp-tcpdump/Dockerfile @@ -0,0 +1,11 @@ +# Use an official Python runtime as a parent image +FROM python:3.9-slim + +# Set the working directory in the container +WORKDIR /app + +# Expose the port that the HTTP server will run on +EXPOSE 8000 + +# Command to run the Python HTTP server +CMD ["python", "-m", "http.server", "8000"] diff --git a/src/41-xdp-tcpdump/README.md b/src/41-xdp-tcpdump/README.md index 6cf898e..f368b29 100644 --- a/src/41-xdp-tcpdump/README.md +++ b/src/41-xdp-tcpdump/README.md @@ -1 +1,35 @@ # Write a tcpdump in XDP to capture packets + +- Write a simple tcpdump in XDP to capture packets +- See how it works in containers + +TODO: Write the document + +Here's a simple `Dockerfile` that sets up a Python environment and runs a basic HTTP server using Python's built-in `http.server` module. The network will allow you to `curl` into the Docker container from your host machine. + +## Steps to build and run the container: + +1. **Build the Docker image:** + Navigate to the directory containing the `Dockerfile` and run: + + ```bash + docker build -t simple-python-http-server . + ``` + +2. **Run the Docker container:** + Run the container and map the internal port `8000` to the host port `8000` so you can access it from your host machine: + + ```bash + docker run -d -p 8000:8000 simple-python-http-server + ``` + + - `-d` runs the container in detached mode (in the background). + - `-p 8000:8000` maps port 8000 of the container to port 8000 on your host machine. + +3. **Access the server:** + Now you can use `curl` to interact with the HTTP server: + + ```bash + curl http://localhost:8000 + ``` +