Use Fluvio in Docker
Docker Compose + Fluvio
You can run Fluvio Clusters in a Docker Compose setup, for a local proof of concept or development.
To run a Fluvio Cluster through Docker, you will need to run Fluvio
components separately, we can use Docker Compose service
s to achieve this.
Services
- sc: Streaming Controller
- sc-setup: Post-Initialization Commands
- spu: Streaming Processing Unit
To learn more about Fluvio architecture, please refer to Fluvio Documentation.
Running
Copy the docker-compose.yaml
and Dockerfile to a directory.
Or clone the Fluvio repo
git clone https://github.com/infinyon/fluvio.git
and cd into./fluvio/examples/docker-compose
docker-compose.yaml
:
version: "3"
services:
sc:
image: infinyon/fluvio:stable
container_name: sc
hostname: sc
ports:
- "9103:9003"
environment:
- RUST_LOG=info
command: "./fluvio-run sc --local /fluvio/metadata"
volumes:
- ./fluvio-metadata:/fluvio/metadata
sc-setup:
build:
context: .
dockerfile: Dockerfile
container_name: sc-setup
environment:
- RUST_LOG=info
entrypoint: >
/bin/sh -c "
fluvio profile add docker sc:9003 docker;
fluvio cluster spu register --id 5001 -p 0.0.0.0:9110 --private-server spu:9011;
exit 0;
"
depends_on:
- sc
spu:
image: infinyon/fluvio:stable
container_name: spu
hostname: spu
volumes:
- ./fluvio-data:/fluvio/data
environment:
- RUST_LOG=info
ports:
- "9110:9010"
- "9111:9011"
command: "./fluvio-run spu -i 5001 -p spu:9010 -v spu:9011 --sc-addr sc:9004 --log-base-dir /fluvio/data"
depends_on:
- sc
Dockerfile
:
FROM ubuntu:20.04
RUN apt-get update
RUN apt-get install -y curl unzip
RUN curl -fsS https://hub.infinyon.cloud/install/install.sh?ctx=dc | bash
ENV PATH "$PATH:/root/.fluvio/bin"
ENV PATH "$PATH:/root/.fvm/bin"
Run docker compose up
.
Optionally you can run on detached mode
docker compose up -d
so Fluvio runs in the background.
Then use the Fluvio CLI to connect to the cluster running in Docker, to do that you must set the Fluvio Profile to point to Docker's container SC:
If you don't have the Fluvio CLI installed on your local machine, run the following command
curl -fsS https://hub.infinyon.cloud/install/install.sh | bash
. Refer to Fluvio CLI Reference for more details.
fluvio profile add docker 127.0.0.1:9103 docker
Fluvio Streaming Controller (SC) usually runs on port
9003
but given that our SC is running in a Docker Container, internal port9003
is mapped to9103
in your system's network.
With the profile set, you are now able to perform Fluvio Client operations like listing topics:
fluvio topics list
Teardown
In order to shutdown the Fluvio Cluster running in Docker, you must issue the
following compose
command:
docker compose down
Remember to run this command in the same directory as the
docker-compose.yml
file.