跳到主要内容
版本:v3

OIBus with Docker

OIBus can be incorporated into a Docker image.

Docker image

The image below takes two optional parameters:

  • arch (default: x64)
  • version

This facilitates the generation of a Docker image featuring a specific version and architecture of OIBus.

To construct a Docker image, two files are required:

  • The initialization script, used for executing certain curl commands from within the container (or none if the file is empty).
  • The Dockerfile, used for building the image containing the OIBus binaries.

Init script

This image necessitates an oibus-init.sh script to dispatch curl commands to OIBus endpoints. If you opt not to incorporate this file, you'll have to execute a curl command from within the Docker manually.

oibus-init.sh
#!/bin/bash

curl --location --request POST 'http://localhost:2223/api/ip-filters' \
--header 'Content-Type: application/json' \
--data-raw '{
"address": "*",
"description": "All"
}' \
-u "admin:pass"

Dockerfile


FROM ubuntu

ARG arch="x64"
ARG version="v3.3.4"

# Install git
RUN apt update -y && apt install -y curl unzip

# Create app directory
WORKDIR /app

RUN curl -LO https://github.com/OptimistikSAS/OIBus/releases/download/${version}/oibus-linux_${arch}-${version}.zip
RUN unzip -a oibus-linux_${arch}-${version}.zip -d OIBus/
WORKDIR /app/OIBus
COPY ./oibus-init.sh .
RUN mkdir OIBusData

# Expose port 2223 for OIBus
EXPOSE 2223

# Start OIBus
CMD ["./oibus-launcher", "--config", "./OIBusData"]

Docker commands

To execute the following commands, ensure that you are in the directory that contains the Dockerfile image.

Build the docker image

docker build -t oibus .

Build the docker image with specific architecture and version

docker build -t oibus --build-arg arch="arm64" --build-arg version="v3.3.2" .

Run a container

docker run --name oibus -d -p 2223:2223 -v "./OIBusData:/app/OIBus/OIBusData" oibus
Docker volume

The volume is not mandatory, but can be useful to access cache, logs, configuration database...

Specific settings in Docker

Web and proxy server port

When using OIBus within a container, the default HTTP port 2223 is exposed. If you wish to access OIBus from a different port, you can modify the docker run command accordingly.

OIBus port

Do not change the HTTP port from the OIBus configuration. You will not be able to access the web page again if you change it.

OIBus proxy server

If you want to use OIBus as a proxy server, you need to update the docker run command to expose the port on which the proxy server listens to.

IP filters

By default, OIBus accepts connections only from localhost by filtering IP. When inside a docker, the IP filter list must be updated.

You can either use the curl command or the init bash script.

Curl command

docker exec -it oibus curl --location --request POST 'http://localhost:2223/api/ip-filters' \
--header 'Content-Type: application/json' \
--data-raw '{
"address": "*",
"description": "All"
}' \
-u "admin:pass"

Bash script

docker exec -it oibus ./oibus-init.sh