Creating nipype_tutorial using Neurodocker

I’m using nipype as a starting point to familiarize myself with Docker image creation. The end goal is to create images for a workshop I’m running this summer.

I’m going through the documentation on repronim, and a lot of things aren’t working. Maybe I can contribute at some point by submitting pull requests or something. In the mean time, I’m just trying something fairly basic to start with.

neurodocker generate docker \
    --pkg-manager apt \
    --base debian:buster-slim \
    --miniconda \
		create_env=jupyter \
        version=latest \
        conda_install="matplotlib notebook numpy pandas seaborn" \
    --user nonroot \
    --workdir /work \
> notebook.Dockerfile

One problem was that --base-image is now --base. Got that.

According to docker scan, there are lots of vulnerabilities with buster, but rolling with that now to simplify.

Now --miniconda wants either create_env or use_env. I went with create_env, and named it jupyter.
When I build the image, it seems to install everything in that environment as expected.

docker build --tag notebook --file notebook.Dockerfile .

However, using that environment when trying to run Jupyter Notebook has me stumped. Just for completeness, here’s my run command line.

docker run --rm -it --workdir /work --volume $PWD:/work --publish 8888:8888  --ip notebook jupyter-notebook

If I run a bash shell in the container, I can’t activate the environment because .bashrc hasn’t been set up. So I conda init bash, then source /home/nonroot/.bashrc, then I can conda activate jupyter and it will run.

So the problem is, how do I conda init bash when creating the image, then conda activate jupyter when the image is run?

I’ve tried this in the first RUN in the Dockerfile:

    &&   echo 'set -e' >> "$ND_ENTRYPOINT" \
    &&   echo 'export USER="${USER:=`whoami`}"' >> "$ND_ENTRYPOINT" \
	&&   echo 'conda init bash' >> "$ND_ENTRYPOINT" \            # added this
	&&   echo 'source $HOME/.bashrc' >> "$ND_ENTRYPOINT" \       # added this
	&&   echo 'conda activate jupyter' >> "$ND_ENTRYPOINT" \     # added this
    &&   echo 'if [ -n "$1" ]; then "$@"; else /usr/bin/env bash; fi' >> "$ND_ENTRYPOINT"; \

Since I’m posting here, you probably suspect this doesn’t work, and you would be right.
It looks like the conda init bash runs, as I see that /home/nonroot/.bashrc has been modified, but when activate runs, it says the shell has not been initialized.


  • Am I missing an updated procedure somewhere?
  • Can I use neurodebian:bullseye which seems to be more secure?
  • How can I create, conda init and conda activate an environment?
  • Can I use the same procedures (whatever those might be) to create the full nipype image as is done here?


just wanted to check this first before moving to the other issues. the current unreleased version does use --base-image (see here. could it be you are using an older version? can you try to install directly from github for now? i’m checking to see if we can make a new release.

Both installation methods from the github README (via the Neurodocker docker image or pip) install version 0.7.0, which seems to allow --base only.

ah i meant something like:

pip install

Thanks @satra , that got me started on the solution.

Here’s a gist of what I wound up doing, in case any Future People™ are looking for a solution.

GitHub unhelpfully sorts the files alphabetically.

  • Install neurodocker first using
  • Download the nipype_tutorial files and create the docker using
  • Change the paths in and give it a try.

Caveat emptor. Void where prohibited. Valid in 49 US states, sorry Tennessee.