mark_l
mark_l

Reputation: 11

Docker causes "one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!" with Snakemake

I'm trying to run a docker container from snakemake. The jobs run and produce the correct output but when they complete I get

(one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)

and snakemake tries to remove the files.

Things I've tried to debug this:

Here is the snakefile rule:

rule run_biospyder:
    input: 
        counts = "{dir}/{name}_counts.csv",
        metadata = "{dir}/{name}_metadata.csv",
    output: directory("{dir}/{name}_output")
    params: 
        dockervol = "/usr/src/data"
    shell:
        """
        docker run \
        -v $PWD:{params.dockervol} biospyderpipeline \
        --config-file {params.dockervol}/config.yml \
        --counts {params.dockervol}/{input.counts} \
        --samples {params.dockervol}/{input.metadata} \
        --output {params.dockervol}/{output} \
        --name {wildcards.name}
        """

Upvotes: 1

Views: 1292

Answers (1)

mark_l
mark_l

Reputation: 11

The issue is a docker permissions issue when mapping volumes. The problem seems to be due to inside container being run as root (I'm just developing) and snakemake tries to write out .snakemake_timestamp as my current user to output directory of the mapped volume (which is owned by root).

I managed to fix it with this: https://denibertovic.com/posts/handling-permissions-with-docker-volumes/

The shell script at the entrypoint creates a user with the same id and runs any commands as that user. This means the mapped volume contents are owned by by user and Snakemake can write to it at the end of the run. This also doesn't fix the user id at the docker build so anyone can use it.

Upvotes: 0

Related Questions