datalad / datalad-container

DataLad extension for containerized environments
http://datalad.org
Other
11 stars 17 forks source link

Add documentation on using the docker adapter manually #248

Open mih opened 1 year ago

mih commented 1 year ago

Scenario: I have a local Dockerfile, I built a local Docker image, I use it locally.

Now I want to preserve this image, I do not care about Docker hub and getting accounts and rate limits and payments and plan. I just have that local Docker image, and I want to use it in a datalad dataset via datalad containers-run.

mih commented 1 year ago

I want the setup described in #197, so I use

❯ cat container/image/.gitattributes
**/*json annex.largefiles=nothing
repositories annex.largefiles=nothing
**/VERSION annex.largefiles=nothing
# build the image and track with datalad
datalad run -m "Build docker image with analysis environment" -i container/Dockerfile -o container/image sh -c "rm -rf container/image; docker build -t remodnav:latest container && python -m datalad_container.adapters.docker save remodnav:latest container/image && echo '**/*json annex.largefiles=nothing\nrepositories annex.largefiles=nothing\n**/VERSION annex.largefiles=nothing' > container/image/.gitattributes"

# register with datalad-container
$ datalad containers-add \
  -i container/image 
  --call-fmt '{python} -m datalad_container.adapters.docker run {img} {cmd}' \
  docker

In my specific case, I want something custom in the docker run setup, but something like this is not possible ATM

--call-fmt '{python} -m datalad_container.adapters.docker run -e HOME=/tmp {img} {cmd}'

I would want to declare options to docker run, maybe like the above, but this is not supported ATM.