AFNI Docker container not working

Hi all!

I’m trying to run AFNI within a Docker container. I start the container with this command: “docker run -it --rm afni/afni:latest”. Although I can use the viewer just fine, few other things seem to work. When I run “ -check_all”, I get the following output:

-------------------------------- general ---------------------------------
architecture:         64bit
system:               Linux
release:              4.19.104-microsoft-standard
version:              #1 SMP Wed Feb 19 06:37:35 UTC 2020
distribution:         Ubuntu 18.04 bionic
number of CPUs:       4
apparent login shell: bash
shell RC file:        .bashrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           : /opt/abin/afni
afni version         : Precompiled binary linux_ubuntu_16_64: May 22 2020
                     : AFNI_20.1.07 'Otho'
AFNI_version.txt     : AFNI_20.1.07, linux_ubuntu_16_64, May 22 2020
which python         : /usr/bin/python
python version       : 2.7.17
which R              : /usr/bin/R
R version            : R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
which tcsh           : /usr/bin/tcsh

instances of various programs found in PATH:
    afni    : 1   (/opt/abin/afni)
    R       : 1   (/usr/bin/R)
    python  : 1   (/usr/bin/python2.7)
    python2 : 1   (/usr/bin/python2.7)
    python3 : 1   (/usr/bin/python3.6)

testing ability to start various programs...
    afni                 : success
    suma                 : success
    3dSkullStrip         : success      : success
    3dAllineate          : success
    3dRSFC               : success
    SurfMesh             : success
    3dClustSim           : success
    3dMVM                : success

checking for R packages...
    rPkgsInstall -pkgs ALL -check : FAILURE

        oo Warning:
           These packages are not installed on the computer: afex!
        These packages are not installed on the computer: phia!
        These packages are not installed on the computer: snow!
        These packages are not installed on the computer: lmerTest!
        These packages are not installed on the computer: paran!
        These packages are not installed on the computer: psych!
        These packages are not installed on the computer: brms!
        These packages are not installed on the computer: corrplot!
        These packages are not installed on the computer: metafor!

R RHOME : /usr/lib/R

checking for $HOME files...
    .afnirc                   : missing
    .sumarc                   : missing
    .afni/help/all_progs.COMP : missing

------------------------------ python libs -------------------------------
++ module loaded: PyQt4
   module file : /usr/lib/python2.7/dist-packages/PyQt4/__init__.pyc

++ module loaded: matplotlib.pyplot
   module file : /usr/lib/python2.7/dist-packages/matplotlib/pyplot.pyc

-------------------------------- env vars --------------------------------
PATH = /opt/abin:/cmake/cmake-3.14.7-Linux-x86_64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin


------------------------------ data checks -------------------------------
data dir : found AFNI_data6   under /opt/src/afni/doc/misc_scripts
           top history: NONE FOUND
data dir : missing AFNI_demos
data dir : missing suma_demo
data dir : missing afni_handouts
atlas    : did not find TT_N27+tlrc

------------------------------ OS specific -------------------------------
which apt-get        : /usr/local/bin/apt-get
apt-get version      : apt 1.6.12 (amd64)

have Ubuntu system: Ubuntu 18.04 bionic
have Ubuntu afni  : Precompiled binary linux_ubuntu_16_64: May 22 2020

=========================  summary, please fix:  =========================
*  login shell 'bash', trusting user to translate code examples from 'tcsh'
*  'afni' executable is owned by root
*  missing R packages (see rPkgsInstall)
*  please run: cp /opt/abin/AFNI.afnirc ~/.afnirc
*  please run: "suma -update_env" for .sumarc
*  please run: apsearch -update_all_afni_help
*  insufficient data for AFNI bootcamp
*  possibly missing atlases

I don’t think I launched the container wrong. I’m wondering if the container itself wasn’t built correctly. What might I be doing wrong?


Hi Ben, thanks for raising the issue. Your command should indeed work. The issue is that you are running it with an older image. The one you probably want to use is afni/afni_make_build. Apologies for the confusion. I will try to delete afni/afni_dev and afni/afni to avoid this for future users.

One thing worth describing a little is the permissions management in the container. I’ll document this soon elsewhere. It roughly follows the approach that Jupyter takes with their docker images: usage of the root user in the container is avoided except where necessary, if you wish to use your user/group ids on your local system you should set specific variables in the container and alter directory permissions as appropriate. Consider using something like the following command (in Bash):

docker run --rm -ti \
    --user root \
    -e CONTAINER_UID=$(id -u) -e CONTAINER_GID=$(id -g) \
    -e CHOWN_EXTRA='/opt/user_pip_packages' \
    -e CHOWN_EXTRA_OPTS='-R' \
    -e CHOWN_HOME=yes \
    -e CHOWN_HOME_OPTS='-R' \
    -e GRANT_SUDO=yes \
    -v $PWD:/mnt \

The CONTAINER_UID/GID variables alter the ids in the container, and the CHOWN variables modify some of the directory permissions in the container (in case you want to install some python packages). --user root is required to run the appropriate commands for this but afterwards the only way for you to execute commands with elevated privileges is by using sudo.

The end result is that you can mount your data directory into the container (here the current working directory into /mnt) and read/write without any issues.

Also note that the R stuff is not installed. I don’t know of a convenient/reliable way to install all of those dependencies.

Let me know if you have any other problems or feature requests.

Thank you! I can tell you put a lot of effort into helping me. I wanted to post that immediately after you replied, but I kept getting an error from this website. Anyway, my lab’s decided that Docker is too much of a hassle to use. From now on, I’m avoiding containers and embracing WSL instead. Once again, I appreciate your help!