ccontainermain allows a Caché, Ensemble or HealthShare product to run in a Docker container.
Docker containers need a PID 1 or main process to hold up the container. This is what
It is developed so that one can quickly work with Caché in a Docker container vs
The name convention used is that of InterSystems commands found in the /bin directory like:
ccontrol, cstart, cforce etc.
ccontainermain is called to run as the main process of a Docker container.
One would copy it in the container and specify it as program to run when issuing a ‘docker run’ command. Alternatively, when using a dockerfile manifesto you would specify
ccontainermain as the ENTRYPOINT command argument. See Docker documentation on Dockerfile declarative manifesto. The typical string found at the end of a Dockerfile would look like:
Please see the dockerfile examples in the [dockerfile] folder above.
ccontainermain start Caché|Ensemble|HealthShare and logs any message and issues to the standard Docker logs output.
It also tries to tune shared memory so that Caché may start. You can pass higher value than the default 512MB that is usually enough to work.
ccontainermain also allows a software developer to start her or his Caché program and also other services.
Here is an example of the syntax on how to fire up a container created via a Dockerfile -with the ENTRYPOINT specified as above, which wraps the call to a java service needed for the app:
$ docker run -p 57772:57772 centos7:C153 -xstart=/myExtraService.sh
However, the most important thing that ccontainermain does is probably the trapping of signals to the container.
Consider the Docker command:
$ docker stop
Docker gives a 10 seconds default and then bring the container down. Not ideal for a database using shared memory.
ccontainermain traps the signal and runs the Caché silent shutdown. Please remember to specify the -t (timeout) flag to the Docker stop command with a value >10 seconds as at times -depending on how busy the system is, it takes longer than that. Of course it all depends if one uses volumes or if one just uses a DB inside the container as an immutable artifact.
ccontainermain offers several flags:
The above flags can also be retrieved via
$ ./ccontainermain -help
For more information on the Caché
ccontrol related options please see:
[InteSystems documentation] (http://docs.intersystems.com/cache201511/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_using_instance#GSA_using_instance_control)
and for the rest see
[the Docker documentation] (https://docs.docker.com/)
Please note that I’ve left in a debug (dbg) constant that you can use to get extra debugging information throughout the program.
For your convenience a linux executable has been provided so that you don’t have to install GO and compile the code.
If you have GO installed simply
$ go build ccontainermain.go
Please also note the dockerfile/ directory under which I’ll try to upload few useful Dockerfile examples. Dockerfiles are Docker engine manifests that allows one to automate Docker images creation.