Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,32 @@ See __--enable-jnat__ below
The toolset is build upon the autotools framework. Run `./autogen.sh` first.
Afterwards `./configure` `make` and `make install` should do the trick.

### Docker

> These commands assume the current working directory is the root of the nfdump repository

To build and run the `nfcapd` target (runs `nfcapd` by default):

```
docker build -t nfcapd --target nfcapd -f extra/docker/Dockerfile .
mkdir -p /tmp/flows
docker run -it --rm --name=nfcapd -p 9995:9995/udp -v /tmp/flows:/data nfcapd
```

Desired arguments to `nfcapd` can be appended to the `docker run` command above.

To build the `nfdump` target (drops you into an interactive shell by default):

```
docker build -t nfdump --target nfdump -f extra/docker/Dockerfile .
mkdir -p /tmp/flows
docker run -it --rm --name=nfdump -v /tmp/flows:/data nfdump
```

For reference, there is also an Ubuntu Dockerfile at _extra/docker/Dockerfile.ubuntu_ with similar `nfcapd` and `nfdump` targets.

### Older Linux-distribution notes

For various older Linuxes need a more modern compiler:

#### CentOS 7.x:
Expand Down
34 changes: 34 additions & 0 deletions extra/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ARG ALPINE_VERSION=3
FROM alpine:${ALPINE_VERSION} AS builder

# Assume context is root of nfdump repository
COPY . /app
RUN apk add --no-cache build-base gcc abuild binutils make \
libtool bzip2-dev libpcap-dev flex bison \
autoconf automake m4 pkgconfig

WORKDIR /app

RUN ./autogen.sh \
&& ./configure --enable-maxmind --enable-nfpcapd --enable-sflow=yes --with-lz4path=/usr --with-zstdpath=/usr --with-bz2path=/usr \
&& make && make install

FROM alpine:${ALPINE_VERSION} AS base

VOLUME /data
RUN apk add --no-cache bzip2-dev libpcap-dev lz4-libs zstd \
&& mkdir -p /data

COPY --from=builder /usr/local /usr/local

FROM base AS nfcapd

EXPOSE 9995/udp

ENTRYPOINT ["/usr/local/bin/nfcapd"]

CMD ["-w", "/data", "-S", "1", "-y", "-p", "9995"]

FROM base AS nfdump

ENTRYPOINT ["/bin/ash"]
31 changes: 0 additions & 31 deletions extra/docker/Dockerfile.alpine

This file was deleted.

58 changes: 29 additions & 29 deletions extra/docker/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#
# Example Ubuntu Dockerfile
# Reference Ubuntu Dockerfile
#

# Pull base image.
FROM ubuntu:latest
ARG UBUNTU_VERSION=24.04
FROM ubuntu:${UBUNTU_VERSION} AS builder

ARG NFDUMP_VERSION=1.7.3
# Assume context is root of nfdump repository
COPY . /app

#Expose netflow port
EXPOSE 9995/udp

# Install.
# Install dependencies
RUN apt-get update && apt-get install -y \
wget \
unzip \
Expand All @@ -26,30 +24,32 @@ RUN apt-get update && apt-get install -y \
flex \
make \
libpcap-dev \
libbz2-dev &&
rm -rf /var/lib/apt/lists/*
libbz2-dev \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app
RUN ./autogen.sh \
&& ./configure --enable-nfpcapd --enable-maxmind --enable-sflow \
&& make && make install \
&& ldconfig

FROM ubuntu:${UBUNTU_VERSION} AS base

RUN cd /usr/src &&
wget https://github.com/phaag/nfdump/archive/refs/tags/v$NFDUMP_VERSION.tar.gz &&
tar xfz v$NFDUMP_VERSION.tar.gz &&
cd nfdump-$NFDUMP_VERSION &&
./autogen.sh &&
./configure --enable-nfpcapd --enable-maxmind --enable-sflow &&
make &&
make install
COPY --from=builder /usr/local /usr/local
RUN apt-get update && apt-get install -y libbz2-dev \
&& rm -rf /var/lib/apt/lists/*

RUN ldconfig
VOLUME /data
RUN mkdir -p /data

FROM base AS nfcapd

EXPOSE 9995/udp

# Add files.
#ADD root/.bashrc /root/.bashrc
#ADD root/.gitconfig /root/.gitconfig
#ADD root/.scripts /root/.scripts
ENTRYPOINT ["/usr/local/bin/nfcapd"]

# Set environment variables.
#ENV HOME /root
CMD ["-w", "/data", "-S", "1", "-y", "-p", "9995"]

# Define working directory.
WORKDIR /usr/src
FROM base AS nfdump

# Define default command.
CMD ["bash"]
ENTRYPOINT ["/bin/bash"]