Prerequisits

  1. You must be on a Linux system with docker installed (v1.28 or higher) (after Jan 2021)
  2. Docker compose must also be installed.

See below for instructions to install docker compose if it is needed.

Steps to run NIFI in Docker container (using docker compose)

Create the docker compose file to start NIFI up

mkdir -p $HOME/play/nifi
cd $HOME/play/nifi

cat <<EOF > docker-compose.yml 
services:
  nifi_test:
    image: apache/nifi:2.0.0
    user: root
    container_name: nifi_test
    ports:
      - "4443:4443"
    environment:
      - NIFI_WEB_HTTPS_PORT=4443
      - SINGLE_USER_CREDENTIALS_USERNAME=nifi_test_user
      - SINGLE_USER_CREDENTIALS_PASSWORD=nifi_test_pass
    healthcheck:
        test: "${DOCKER_HEALTHCHECK_TEST:-curl localhost:4443/nifi/}"
        interval: "60s"
        timeout: "3s"
        start_period: "5s"
        retries: 5
    volumes:
      - nifi_data:/opt/nifi/nifi-current/data
      - nifi_logs:/opt/nifi/nifi-current/logs
      - nifi_conf:/opt/nifi/nifi-current/conf # persist NiFi flows

volumes:
  nifi_data:
  nifi_logs:
  nifi_conf:

EOF

Docker compose explained

This portion of the docker compose file contains some important information

services:
  nifi_test:                      # Defines a service named "nifi_test"
    image: apache/nifi:2.0.0      # Uses the official Apache NiFi 2.0.0 Docker image
    user: root                    # Runs the container as the "root" user (needed for certain permissions, but not always recommended)
    container_name: nifi_test     # Sets a fixed container name (visible in `docker ps`)
    ports:
      - "4443:4443"               # Maps port 4443 on the host to port 4443 inside the container (HTTPS access)
    environment:
      - NIFI_WEB_HTTPS_PORT=4443  # Configures NiFi to run its web UI over HTTPS on port 4443
      - SINGLE_USER_CREDENTIALS_USERNAME=nifi_test_user  # Defines the single-user login username for NiFi
      - SINGLE_USER_CREDENTIALS_PASSWORD=nifi_test_pass  # Defines the single-user login password for NiFi

To start up NIFI run

Next, start NIFI using the docker compose command shown next

docker compose up nifi_test -d
docker ps

This will start a couple docker containers one of which hosts the webpage The NiFi container is exposing several ports, but only port 4443 is mapped to the host. Ports 8000, 8443, and 10000 are only available inside the Docker network and not accessible directly from your host.

Login to NIFI

Lastly, once it is running you can login to the web server that is being run inside docker using: https://localhost:4443/nifi/

username: nifi_test_user       
password: nifi_test_pass

Installing docker compose

On an Ubuntu 22.x system I had docker installed but not docker compose. To install it I used

mkdir -p ~/.docker/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
chmod +x ~/.docker/cli-plugins/docker-compose

Docker Compose for all users on your system, replace ~/.docker/cli-plugins with /usr/local/lib/docker/cli-plugins. A different version of Compose, substitute v2.12.2 with the version of Compose you want to use. Apply executable permissions to the binary:

NOTE: docker also supports this being installed for all users at /usr/local/lib/docker/cli-plugins/docker-compose

To verify it’s been installed properly run this command

docker compose version
Docker Compose version v2.3.3

<
Previous Post
How can I find files updated in last 5 minutes
>
Next Post
How can I install Node using nvm?