Sign in

fail2ban

1.1.0-r2-ls10

Fail2ban is a daemon to ban hosts that cause multiple authentication errors.

docker pull ghcr.io/linuxserver-playground/fail2ban:latest

Quick start · configure#

Pick the optional settings and mods you want, set your paths, ports and values, then copy the result.

Image
Identity

The user the application runs as and its timezone.

Required
Persistent config files
Host logs. Mounted as Read Only.
  • cap_add: NET_ADMIN Required for fail2ban to be able to modify iptables rules.
  • cap_add: NET_RAW Required for fail2ban to be able to bind to any interface & use RAW sockets.
  • network_mode: host Host networking: the container uses the host's network directly, so the port mappings are left out.
Optional settings18

Tick what you need; it is added to every output with its value.

Mods

0 for fail2ban, 0 universal mods suggested for it, and 13 other universal mods. Ticked mods join one DOCKER_MODS value in the order you tick them.

---
services:
  fail2ban:
    image: ghcr.io/linuxserver-playground/fail2ban:latest
    container_name: fail2ban
    cap_add:
      - NET_ADMIN
      - NET_RAW
    network_mode: host
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
    volumes:
      - /path/to/fail2ban/config:/config
      - /var/log:/var/log:ro
    restart: unless-stopped

Required settings only. Tick optional settings and mods to add them.

  • Replace the /path/to folders with real folders on your host; they are created if missing.
  • Host networking: the container uses the host's network directly, so the port mappings are left out.

Install on …

Adding a store to your platform

Version tags#

TagLatest buildBuiltTests
:latestStable releasesbranch main · stable1.1.0-r2-ls10amd64 · arm64 passed

Architectures#

Pulling :latest picks the right one for your host automatically.

  • x86_64amd64-latest
  • arm64arm64v8-latest

Inside the latest image#

ghcr.io/linuxserver-playground/fail2ban:1.1.0-r2-ls10

Explore this build
Base image
ghcr.io/linuxserver-playground/baseimage-alpine:3.21
Upstream version
1.1.0-r2
amd64 compressed
29.0 MB · 9 layers
arm64 compressed
30.0 MB · 9 layers
amd64 packages
90 · Alpine Linux v3.21
arm64 packages
90 · Alpine Linux v3.21
Tests
passed
Built
Reason
weekly package check

In the fleet#

Live branches, their latest release, upstream version and next scheduled check.

fail2ban on the fleet board

live branchesloading…

Branch → tagLast buildReleasedUpstreamDriftNext checkFlags
main → :latestsuccess
1.1.0-r2
? unknown––

Application setup#

This container is designed to allow fail2ban to function at the host level, as well as at the docker container level. If you are running applications on the host, you will need to set the chain to INPUT in the jail for that application.

Configuration Files

On first run, the container will create a number of folders and files in /config. The default configurations for fail2ban are all disabled by default.

Please refer to the Configuration README, which can be viewed in our repository, or in your config folder at /config/fail2ban/README.md.

Remote Logs

All jails require the ability to read the application log files. We recommend mounting each application’s log folder as a volume to the container (illustrated by the optional volumes in our documentation). Mounting individual log files can cause issues and is not recommended.

The /remotelogs path is designed to act as a parent for all log files you would like fail2ban to be able to use. Each log file should be mounted in a subfolder underneath /remotelogs, ex:

  • /remotelogs/nginx/ would mount a folder containing the nginx logs to the container

Parameters#

Environment variables#
VariableFunctionRequired
PUID=1000User IDrequired
PGID=1000Group IDrequired
TZ=Etc/UTCTimezonerequired
VERBOSITY=-vvSet the container log verbosity. Valid options are -v, -vv, -vvv, -vvvv, or leaving the value blank or not setting the variable.optional
Volumes#
PathFunctionRequired
/configPersistent config filesrequired
/var/log:roHost logs. Mounted as Read Only.required
/remotelogs/airsonic:roOptional path to airsonic log folder. Mounted as Read Only.optional
/remotelogs/apache2:roOptional path to apache2 log folder. Mounted as Read Only.optional
/remotelogs/authelia:roOptional path to authelia log folder. Mounted as Read Only.optional
/remotelogs/emby:roOptional path to emby log folder. Mounted as Read Only.optional
/remotelogs/filebrowser:roOptional path to filebrowser log folder. Mounted as Read Only.optional
/remotelogs/homeassistant:roOptional path to homeassistant log folder. Mounted as Read Only.optional
/remotelogs/lighttpd:roOptional path to lighttpd log folder. Mounted as Read Only.optional
/remotelogs/nextcloud:roOptional path to nextcloud log folder. Mounted as Read Only.optional
/remotelogs/nginx:roOptional path to nginx log folder. Mounted as Read Only.optional
/remotelogs/nzbget:roOptional path to nzbget log folder. Mounted as Read Only.optional
/remotelogs/overseerr:roOptional path to overseerr log folder. Mounted as Read Only.optional
/remotelogs/prowlarr:roOptional path to prowlarr log folder. Mounted as Read Only.optional
/remotelogs/radarr:roOptional path to radarr log folder. Mounted as Read Only.optional
/remotelogs/sabnzbd:roOptional path to sabnzbd log folder. Mounted as Read Only.optional
/remotelogs/sonarr:roOptional path to sonarr log folder. Mounted as Read Only.optional
/remotelogs/unificontroller:roOptional path to unificontroller log folder. Mounted as Read Only.optional
/remotelogs/vaultwarden:roOptional path to vaultwarden log folder. Mounted as Read Only.optional
Other settings#
SettingFunctionRequired
cap_add: NET_ADMINRequired for fail2ban to be able to modify iptables rules.required
cap_add: NET_RAWRequired for fail2ban to be able to bind to any interface & use RAW sockets.required
network_mode: hostRuns on the host network.required

Environment variables from files (Docker secrets)#

You can set any environment variable from a file by using a special prepend FILE__.

As an example:

-e FILE__MYVAR=/run/secrets/mysecretvariable

Will set the environment variable MYVAR based on the contents of the /run/secrets/mysecretvariable file.

Umask for running applications#

For all of our images we provide the ability to override the default umask settings for services started within the containers using the optional -e UMASK=022 setting. Keep in mind umask is not chmod it subtracts from permissions based on it’s value it does not add. Please read up here before asking for support.

User / Group Identifiers#

When using volumes (-v flags), permissions issues can arise between the host OS and the container, we avoid this issue by allowing you to specify the user PUID and group PGID.

Ensure any volume directories on the host are owned by the same user you specify and any permissions issues will vanish like magic.

In this instance PUID=1000 and PGID=1000, to find yours use id your_user as below:

id your_user

Example output:

uid=1000(your_user) gid=1000(your_user) groups=1000(your_user)

Updating Info#

Most of our images are static, versioned, and require an image update and container recreation to update the app inside. With some exceptions (noted in the relevant readme.md), we do not recommend or support updating apps inside the container. Please consult the Application Setup section above to see if it is recommended for the image.

Below are the instructions for updating containers:

Via Docker Compose

  • Update images:

    • All images:

      docker-compose pull
    • Single image:

      docker-compose pull fail2ban
  • Update containers:

    • All containers:

      docker-compose up -d
    • Single container:

      docker-compose up -d fail2ban
  • You can also remove the old dangling images:

    docker image prune

Via Docker Run

  • Update the image:

    docker pull ghcr.io/linuxserver-playground/fail2ban:latest
  • Stop the running container:

    docker stop fail2ban
  • Delete the container:

    docker rm fail2ban
  • Recreate a new container with the same docker run parameters as instructed above (if mapped correctly to a host folder, your /config folder and settings will be preserved)

  • You can also remove the old dangling images:

    docker image prune

Image Update Notifications - Diun (Docker Image Update Notifier)

Tip

We recommend Diun for update notifications. Other tools that automatically update containers unattended are not recommended or supported.

Building locally#

If you want to make local modifications to these images for development purposes or just to customize the logic:

git clone https://github.com/linuxserver-playground/docker-fail2ban.git
cd docker-fail2ban
docker build \
  --no-cache \
  --pull \
  -t ghcr.io/linuxserver-playground/fail2ban:latest .

The ARM variants can be built on x86_64 hardware and vice versa using ghcr.io/linuxserver/qemu-static

docker run --rm --privileged ghcr.io/linuxserver/qemu-static --reset

Once registered you can define the dockerfile to use with -f Dockerfile.aarch64.

Every push builds and tests the image with the shared workflow in linuxserver-playground/workflows; every build’s tests, screenshots and package changes are on the image’s builds on the website.

Builds#

The newest five builds per branch, each with its CI report; 5 older releases are on GitHub, listed below.

TagBuiltReasonChangeResultSize
1.1.0-r2-ls10main · 9b92c7a6weekly package checkbasesuccess29.0 MB amd6430.0 MB arm64
1.1.0-r2-ls9main · 832eff73weekly package checkpackagessuccess29.0 MB amd6430.1 MB arm64
1.1.0-r2-ls8main · b2bdae0fweekly package checkbasesuccess29.0 MB amd6430.1 MB arm64
1.1.0-r2-ls7main · 4e16189bweekly package checkbasesuccess29.1 MB amd6430.2 MB arm64
1.1.0-r2-ls6main · 1b11ea4eweekly package checkbasesuccess29.1 MB amd6430.2 MB arm64
Older releases5Release, run record and run on GitHub

Mods#

Add a mod with DOCKER_MODS=<image>; separate several with |.

All mods for fail2ban

No mod targets fail2ban specifically; the 13 universal mods work with every image.

Changelog#

  1. Rebase to Alpine 3.21.

  2. Rebase to Alpine 3.20.

  3. Rebase to Alpine 3.19.

  4. Add optional VERBOSITY environment variable, allowing users to set the container log verbosity.

  5. Rebase to Alpine 3.18, deprecate armhf.

  6. Replace unmaintained ssmtp with msmtp.

  7. Rebase to Alpine 3.17, Add ssmtp and whois packages. Symlink config to allow live reloading.

  8. Update README to clarify remote log information.

1 earlier entries
  1. Initial Release.

Support#

Questions about running fail2ban? Start with the documentation and the community; open an issue for bugs.

  • Shell access whilst the container is running:

    docker exec -it fail2ban /bin/bash
  • To monitor the logs of the container in realtime:

    docker logs -f fail2ban
  • Container version number:

    docker inspect -f '{{ index .Config.Labels "build_version" }}' fail2ban
  • Image version number:

    docker inspect -f '{{ index .Config.Labels "build_version" }}' ghcr.io/linuxserver-playground/fail2ban:latest

Community project

Improve fail2ban

This image is kept up by volunteers, and you can be one of them. You don't need to know how the pipeline works: point an AI agent at the harness and describe what you want. It reproduces the problem in your Docker, tests the change and drafts the pull request for you to check.

Ask your agent

  • Something is wrong with the fail2ban image: <what you saw>. Reproduce it, fix it and draft the PR.
  • Add <package> to the fail2ban image, test it and draft the PR.
  • Make a mod for fail2ban that <what you need>, and test it.

Contributing an image Every way to help Get the harness (opens in a new tab)

Writing

Posts about fail2ban

2 min read

Introducing SWAG Dashboard

SWAG Dashboard is a mod powered by GoAccess that provides a comprehensive overview of SWAG's operation. Follow latest the instructions on the mod's readme to set it up. Navigate…

Related

Browse all

adguardhome-sync

v0.10.1-ls9

Adguardhome-sync is a tool to synchronize AdGuardHome config to replica instances.

0 GitHub starsalpinearm64

ddclient

v4.0.0-ls5

Ddclient is a Perl client used to update dynamic DNS entries for accounts on Dynamic DNS Network Service Provider. It was originally written by Paul Burry and is now mostly by wimpunk. It has the capability to update more than just dyndns and it can fetch your WAN-ipaddress in a few different ways.

0 GitHub starsalpinearm64

duckdns

8d26a150-ls8

Duckdns is a free service which will point a DNS (sub domains of duckdns.org) to an IP of your choice. The service is completely free, and doesn't require reactivation or forum posts to maintain its existence.

0 GitHub starsalpinearm64

kali-linux

42353ed8-ls13

Kali-linux - is an Advanced Penetration Testing Linux distribution used for Penetration Testing, Ethical Hacking and network security assessments. KALI LINUX ™ is a trademark of OffSec.

0 GitHub starsselkiesarm64