# Using a local Dockerfile based on renv.lock

**URL:** <https://cwl.discourse.group/t/using-a-local-dockerfile-based-on-renv-lock/941>\
**Category:** CWL Questions\
**Created:** [August 6, 2024, 12:42pm UTC](https://cwl.discourse.group/t/using-a-local-dockerfile-based-on-renv-lock/941 "2024-08-06T12:42:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brilator](https://yyz2.discourse-cdn.com/free1/user_avatar/cwl.discourse.group/brilator/32/565_2.png) [@Brilator](https://cwl.discourse.group/u/Brilator)\
**Post date:** [August 6, 2024, 12:42pm UTC](https://cwl.discourse.group/t/using-a-local-dockerfile-based-on-renv-lock/941/1 "2024-08-06T12:42:07Z")

</div>

Hi everyone,

in order to use and share an R script with CWL, I am trying to create and reference a Dockerfile based on the R package `renv`; mostly following the renv + docker instructions: ([Using renv with Docker • renv](https://rstudio.github.io/renv/articles/docker.html) and [Docker – Solutions](https://solutions.posit.co/envs-pkgs/environments/docker/#r)).

Does anyone have experience with that combination?

My `Dockerfile` looks like this:

```auto
## Use pre-built base image coming with R and required system libraries
FROM rstudio/r-base:4.3-jammy

## Install package `renv` to Docker image
RUN R -e "install.packages('renv', repos = c(CRAN = 'https://cloud.r-project.org'))"

## Pull in renv.lock and restore it
COPY *renv.lock ./
RUN R -e "renv::restore()"

```

The Dockerfile works fine with `docker build ... `.

However, when using it in my CommandLineTool, it throws an error, which I assume comes from renv.lock not being properly copied / found:

> Workflow or tool uses unsupported feature:  
> Docker is required to run this tool: Command …

My CWL:

```auto
#!/usr/bin/env cwl-runner
cwlVersion: v1.2
class: CommandLineTool

requirements:
    ShellCommandRequirement: {}
    InitialWorkDirRequirement:
      listing:
        - entryname: renv.lock
          entry:
            $include: "./renv.lock"
    DockerRequirement:
        dockerFile: {$include: "./Dockerfile"}
        dockerImageId: "renv-docker-test"

...

```

I must admit I also don’t have much experience with Docker, so my apologies if that’s a trivial issue.

Or can somebody point me to an easier / better alternative resource to handling R dependencies with CWL?

Thanks!

---

<div class="post-metadata">

**Author:** ![mrc](https://yyz2.discourse-cdn.com/free1/user_avatar/cwl.discourse.group/mrc/32/3_2.png) [@mrc](https://cwl.discourse.group/u/mrc)\
**Post date:** [November 5, 2024, 1:07pm UTC](https://cwl.discourse.group/t/using-a-local-dockerfile-based-on-renv-lock/941/2 "2024-11-05T13:07:33Z")

</div>

Hello @Brilator  
In CWL, when you use the `dockerFile` feature, you can’t use `COPY` commands.

Can you open an issue with `cwltool` so we have a better error message?
