gnu-octave/docker

Cannot install netcdf

grgdll opened this issue ยท 7 comments

Hi there,

It's the first time I use docker/singularity, so please forgive me if I am asking something really obvious.

I've installed the docker image for octave-6.4.0 and I can start octave.

However, I now would need to install netcdf using pkg install -forge -verbose netcdf, but this command stops with the following output:

`octave:2> pkg install -forge -verbose netcdf
mkdir (/tmp/oct-tqi5Uw)
untar (/tmp/netcdf-1.0.14-1u9tra.tar.gz, /tmp/oct-tqi5Uw)
checking for gawk... gawk
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for mkoctfile... /usr/bin/mkoctfile-6.4.0 --verbose
checking for nc-config... no
configure: error: nc-config not found

error: pkg: error running the configure script for netcdf.
error: called from
configure_make at line 93 column 9
install at line 196 column 7
pkg at line 568 column 9`

I have checked (outside of octave) and nc-info is installed on my machine. I think docker/singularity cannot find its location, but I do not know how to pass this information.

Any help will be greatly appreciated.

Many thanks in advance,
grg

Thank you very much for using this Octave version ๐Ÿ™‚

According to the netcdf package libnetcdf-dev must be installed. This is not installed by default in the Octave Docker images.

However, depending on how you started the Octave Docker images (I use https://github.com/gnu-octave/docker#starting-the-octave-gui), the following might work. Type the following commands directly in the started Octave command window:

system ("sudo apt update")
system ("sudo apt install libnetcdf-dev")
pkg install -forge netcdf

Many thanks for the quick response!

I tried your suggestion, but it did not work:

octave:2> system ("sudo apt update")
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
ans = 1
octave:3>

Any clue?
thanks again!

How do you start he Octave Docker images?

The docker installation has created a subdirectory in my $HOME called bin in which there is an executable: ~/bin/octave
I use this executable to start the Octave Docker image

I've tried starting Octave as sudo, and I was able to run system('sudo dnf update'), (I'm on Fedora and apt was not found when I tried your command) but then when I try to run system('sudo dnf install netcdf-devel') I get this message:

Package netcdf-devel-4.4.1.1-10.fc29.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

Not sure how to proceed.
thanks

PS: this is what's inside the ~/bin/octave executable

#!/bin/sh

OCTAVE_VERSION="${OCTAVE_VERSION:-"6.4.0"}"

DOCKER_INTERACTIVE="-it"
for arg in "$@"
do
  if [[ "$arg" == "--gui" ]]
  then
    DOCKER_INTERACTIVE=""
  fi
  # Old Octave qt4 builds
  if [[ "$arg" == "--force-gui" ]]
  then
    DOCKER_INTERACTIVE="--env=QT_GRAPHICSSYSTEM=native"
  fi
done

## Avoid collisions with different 'OCTAVE_VERSION's
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
OCTAVE_CONF_DIR="$XDG_CONFIG_HOME/octave"
OCTAVE_CONF_DIR_HOST="$OCTAVE_CONF_DIR/$OCTAVE_VERSION"
mkdir -p "$OCTAVE_CONF_DIR_HOST"

singularity exec --bind /run/user,$OCTAVE_CONF_DIR_HOST:$OCTAVE_CONF_DIR myhome/bin/octave_jupyterlab.sif "${0##*/}" "$@"

Thanks for the info ๐Ÿ‘ When Singularity has converted the Docker images to a SIF file, those are hardly changeable.

There are several options:

  1. Use Docker and build & run a custom image. Save the following as Dockerfile:
FROM gnuoctave/octave:6.4.0

USER root

RUN apt-get --yes update         && \
    DEBIAN_FRONTEND="noninteractive" \
    apt-get --no-install-recommends --yes install \
      libnetcdf-dev              && \
    apt-get --yes clean          && \
    apt-get --yes autoremove     && \
    rm -Rf /var/lib/apt/lists/*

USER ${NB_UID}

RUN octave --eval "pkg install -forge netcdf"

WORKDIR "${HOME}"

ENTRYPOINT ["/usr/local/bin/start.sh"]
CMD ["octave-cli"]

and run

docker build -t grgdll/octave:6.4.0 -f Dockerfile .

Then use grgdll/octave:6.4.0 instead of gnuoctave/octave:6.4.0.

  1. Stay with Singularity and do something similar to above translating a Dockerfile to a Singularity definition file (quite similar):

There are certainly more options, but those two are the ones with probably lead to the fastest success. If you get stuck, please let me know ๐Ÿ™‚

It worked, thanks so much!