Support custom Docker image when using Kubernetes

Issue #602 resolved
Liang-Bo Wang created an issue

Thanks for supporting Kubernetes and Google Container Engine. It is very promising to have snakemake run on a scalable cloud. I was wondering if there could be an option to let user specify which Docker image.

Currently the Docker image is fixed to the official snakemake image on

# From snakemake/
# container
container = kubernetes.client.V1Container()
container.image = "{}".format(__version__)
container.command = shlex.split(exec_job)

If one can pass in a different Docker image, one can bundle all the tools within the image. The nice thing of having such image is that it can be run everywhere. Although currently one can already install custom dependencies via bioconda, passing user specified Docker image will make snakemake more flexible.

One of the possible implementation could be passing an extra command-line argument, but i don't have strong opinion.

Please let me know what you think. Thanks!

Comments (7)

  1. Johannes Köster

    THis is certainly a reasonable request. I have not done it so far, because any image that one would specify will have to contain Snakemake itself. Even more, for a reliable experience, it will have to be almost the same version as the master process (because e.g. some arguments are passed and a different Snakemake version could expect something else). Hence, I am currently more looking into singularity as an alternative to conda. This (a) runs in more contexts, and (b) would I think also flawlessly run within the Snakemake docker container. So, one could write:

    rule a:
        input: ...
        output: ...

    In any execution environment, Snakemake would then start the container before running the shell command.

  2. Liang-Bo Wang reporter

    I heard Singularity from bioconda and it is indeed gaining momentum in the community. I am glad that you have been working on a solution. Please let me know if there is any git branch or place to follow the update, or if there anything open for contribution. Thanks!

  3. Jeffrey Tratner

    @ccwang002 - I believe you could accomplish this right now by writing a wrapper to add in the correct singularity commands into your run script (but it'd definitely be hacky :P )

  4. Liang-Bo Wang reporter

    I think one of the difficulties adopting singularity is that the host machine needs to install it which requires a special image during deployment. As for Docker it is more ubiquitous and it is available by default on Google Cloud.

    So now i basically just ship a modified version of snakemake which points to my own Docker image while running Kubernetes. I will dive more into Singularity once it gets official snakemake support :)

  5. Johannes Köster

    You know what, before you have to ship your fork, I will give you the cli option ;-).

    The idea with singularity will be that the default snakemake docker image will ship it. Hence, it will hopefully work just out of the box, everywhere where docker is available.

  6. Log in to comment