The ARG instruction defines a variable that users can pass at build-time to the builder with the docker build
Docker images defined in your example ( i.e. openidentityplatform/opendj:4.2.4) have already been built so there is no build command invoked, and therefore no way to alter build-time behavior.
Depending on how OpenDJ containers are designed, providing a variable under environment might override the runtime behavior, but that would depend on OpenDJ’s implementation.
If the container does not respect an environment variable at runtime, then your other options include:
Build (with args) and publish the images yourself to a public or private registry to be used at runtime, i.e. openidentityplatform/opendj:4.2.4-dn1 and openidentityplatform/opendj:4.2.4-dn2
Invoke docker build within the job itself to first build and then run (you could use your provided docker compose). You would need to choose a machine executor or setup_remote_docker, noting the networking constraints with the latter.
I’d also suggest that if this project is open source and under active maintenance, you could approach the project and ask for env settings to be added.
OpenDJ is open source and I recently changed the way the container works from ENV to ARG because ENV variables were used in the build process and so passing them in during docker run had no affect.
The Dockerfile is quite simple and you can see that we need to set the base_dn when we run /opt/opendj/setup to initialize the server. I don’t think we could do this with ENV vars at runtime.