Docker Community Forums

Share and learn in the Docker community.

How can we create docker image for an interactive installer (ISO based) that prompts for user inputs, e.g. for DB HOST/Port?

How can we create docker image for an interactive installer that prompts for user inputs, e.g. for DB HOST/Port?
If currently installer is ISO based, then what is best approach to dockerize?

Do we need to write dockerfile that wraps ISO based installer (setupLinux.bin) and run it at spawning of container, so that user inputs can be passed?
Or,
Do we need to write Dockerfile, by assembling all the binaries/libs/jars along with the configuration steps, files etc… afresh, making static parts of image, and any dynamic stuff, be taken as environment setting/input at time of container start?

I believe that you can use -e to pass in variables.

docker run -d -t -i -e DBHost='SQLSERVER' \ 
-e DBPort ='PortNumber' \
--name container_name dockerhub_id/image_name

Thanks for the information about passing variables, but problem is that I can only pass those variables at time of my installer is run, hence if i reuse my existing installer (silent install with response file) during container spawning, it will save me lot of efforts. Alternatively, I will need to repackage the bins/libs and rewrite the configuration scripts/steps, so that I can allow these configurations at install time currently to be shifted to run-time (container spawn time).

Which is the usual approach?

The approach to install the application on container start is a desaster when used with Swarm or Kubernetes, as the container will be created everytime from the scratch! A container should start within seconds.

Usualy an image contains an installed application, all its dependencies and entrypoint scripts that modify configuration files on container start using passed in ENV parameters.

Make sure to include those ENV variables in your Dockerfile and assign a usefull default value to them. Also you want to fail the container start if required parameters are not passed in as -e “parameter”.

Thanks, yes i understand this. If I don’t reuse my existing installer, it will mean I will need to put all static part in my image, and all dynamic parts shall be moved to configuration scripts controlled via environment variables passed during container spawn…

This will involve much rework/redesign of some aspects to be able to create images. Thanks.

Thats what your entrypoint scripts should do, either by using a template engine (dockerize is amazingly small and has a simple to use template engine) to render the ENV values into the configuration files, or by replacing the settings in your config files with the ENV values (sed, xmlstarlet, and such are helpful here), before the main service is started.

Thanks for information, appreciate it.