You can dockerize/containerize pretty much anything fairly easily. You basically just have to add a Dockerfile that:
- Inherits from some base image; this provides the basic OS features and whatever else you need. E.g. a Java app may inherit from alpine-jdk-8 (a slim linux type image) that comes pre-bundled with the Java Development Kit.
- Copies in your code and any dependencies.
- Sets any variables you require.
- Exposes any ports your app needs (e.g. ports 80/443 for serving a web page).
- Mounts any volumes to save permanent data. Generally anything in a container is ephemeral; it will be gone when the container dies. So, if you want to save/export results permanently you can mount a volume for, say, your local computer's file system, or for an amazon s3 bucket, or whatever.
- Specifies how to start the app (the entry point).
Here's an example for arbitrary python scripts; but it's the same deal for any other language/tool:
If you're taking an existing executable which may be your case, you just do the same thing but instead of loading in your code, you load in the binary and set that as your entry point.
The container lives until the entry point program ends. So, some containers can be short lived - like just executing a CURL or something. Some are permanent until they die/are killed (e.g. a web service).
Again, to save state/results, unless you're writing them to a database or some other external system, you will want to mount a volume.
You build your Dockerfile into an image with a docker build command; then it will show up in your local docker image registry (
docker image ls -a). After that, you can run it with a standard docker run command (where you will likely want to expose any ports/etc that are needed). I assume you're good with this one since you already run existing images in docker.
Generally you will need to store your image in a registry so you can use it on/from other systems. But if running it locally is all you need you're done now :).
You can store your own containers in DockerHub or in Amazon AWS ECR or in any other number of options if you require a registry.