Skip to content

Commit

Permalink
update the docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwei37 committed Sep 8, 2024
1 parent 886948d commit bb31100
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/41-xdp-tcpdump/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
34 changes: 34 additions & 0 deletions src/41-xdp-tcpdump/README.md
Original file line number Diff line number Diff line change
@@ -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
```

0 comments on commit bb31100

Please sign in to comment.