Skip to content

installing micromamba in docker (error message "error: process ID out of range" is fixable) - AND non-root user needs to call ~/.local/bin/micromamba but root can call micromamba without path information. #68

@ifrh

Description

@ifrh

When installing Micromamba by calling the installation script within a file that is processed by docker build, error messages occur.

Micromamba has been installed once for root and once for a non-root user within the container.

In the Dockerfile Micromamba can be called without specifying a path for root users after installation.

However, when not using root, the path to Micromamba must always be included when calling it in the Dockerfile.

For installation in Dockerfile I use that line

RUN bash <(curl -L micro.mamba.pm/install.sh)

I adapted the information from here:

```bash
"${SHELL}" <(curl -L https://micro.mamba.pm/install.sh)
```

Build output with error message

#29 [25/68] RUN bash <(curl -L micro.mamba.pm/install.sh)
#29 0.774   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#29 0.776                                  Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  3059  100  3059    0     0   6606      0 --:--:-- --:--:-- --:--:-- 15068
#29 1.257 error: process ID out of range
#29 1.257 
#29 1.257 Usage:
#29 1.257  ps [options]
#29 1.257 
#29 1.257  Try 'ps --help <simple|list|output|threads|misc|all>'
#29 1.257   or 'ps --help <s|l|o|t|m|a>'
#29 1.257  for additional help text.
#29 1.257 
#29 1.257 For more details see ps(1).

The error message comes from that code line in installation script:

parent=$(ps -o comm $PPID |tail -1)

Build output with error message

I found while docker build the value of $PPID is 0.

Adding a pair of braces in the RUN command of dockerfile, the error went away.
RUN (bash <(curl -L micro.mamba.pm/install.sh))


#30 [26/68] RUN (bash <(curl -L micro.mamba.pm/install.sh))
#30 0.669   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#30 0.669                                  Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  3059  100  3059    0     0  18317      0 --:--:-- --:--:-- --:--:-- 18317
#30 2.272 Modifying RC file "/root/.bashrc"
#30 2.272 Generating config for root prefix "/root/micromamba"
#30 2.272 Setting mamba executable to: "/root/.local/bin/micromamba"
#30 2.272 Adding (or replacing) the following in your "/root/.bashrc" file
#30 2.272 
#30 2.272 # >>> mamba initialize >>>
#30 2.272 # !! Contents within this block are managed by 'micromamba shell init' !!
#30 2.272 export MAMBA_EXE='/root/.local/bin/micromamba';
#30 2.272 export MAMBA_ROOT_PREFIX='/root/micromamba';
#30 2.272 __mamba_setup="$("$MAMBA_EXE" shell hook --shell bash --root-prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
#30 2.272 if [ $? -eq 0 ]; then
#30 2.272     eval "$__mamba_setup"
#30 2.272 else
#30 2.272     alias micromamba="$MAMBA_EXE"  # Fallback on help from micromamba activate
#30 2.272 fi
#30 2.272 unset __mamba_setup
#30 2.272 # <<< mamba initialize <<<
#30 2.272 
#30 2.281 Please restart your shell to activate micromamba or run the following:\n
#30 2.281   source ~/.bashrc (or ~/.zshrc, ~/.xonshrc, ~/.config/fish/config.fish, ...)
#30 DONE 2.6s

After sourcing ~/.bashrc micromamba could be used by root user in docker container.


#31 [27/68] RUN hash -r ;    source ~/.bashrc ;    micromamba info
#31 0.800 
#31 0.800        libmamba version : 2.0.2
#31 0.800      micromamba version : 2.0.2
#31 0.800            curl version : libcurl/8.10.1 OpenSSL/3.3.2 zlib/1.3.1 zstd/1.5.6 libssh2/1.11.0 nghttp2/1.58.0
#31 0.800      libarchive version : libarchive 3.7.4 zlib/1.2.13 bz2lib/1.0.8 libzstd/1.5.6
#31 0.800        envs directories : /root/micromamba/envs
#31 0.800           package cache : /root/micromamba/pkgs
...

Sadly installing Micromamba for a non-root user via Dockerfile has more problems
a) The installation gives above error message about process id, too. Fixable by using an additional pair of braces in RUN command.
b) After installation micromamba is not callable after sourcing ~/.bashrc without path.

Content of dockerfile for installing micromamba for non-root user
I have used echo and cat and grep for debugging downbelow, but did not find the reason.

ARG USERNAME=appuser
RUN useradd --create-home ${USERNAME}
WORKDIR /home/${USERNAME}
USER ${USERNAME}
# Install micromamba for non-root user
RUN (bash <(curl -L micro.mamba.pm/install.sh))
RUN echo ~/.bashrc
RUN cat ~/.bashrc | grep mamba
RUN hash -r ; \    
    source ~/.bashrc ; \
    ~/.local/bin/micromamba --version ; \
    ~/.local/bin/micromamba shell init -s bash -r ~/micromamba
RUN hash -r ; \    
    source ~/.bashrc ; \
    micromamba info || /bin/true ; \
    ~/.local/bin/micromamba info

Installation output without error message, because of additional brace in RUN-line:

#37 [33/68] RUN (bash <(curl -L micro.mamba.pm/install.sh))
#37 0.655   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#37 0.655                                  Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  3059  100  3059    0     0  21695      0 --:--:-- --:--:-- --:--:-- 21695
#37 2.247 Modifying RC file "/home/appuser/.bashrc"
#37 2.247 Generating config for root prefix "/home/appuser/micromamba"
#37 2.247 Setting mamba executable to: "/home/appuser/.local/bin/micromamba"
#37 2.247 Adding (or replacing) the following in your "/home/appuser/.bashrc" file
#37 2.247 
#37 2.247 # >>> mamba initialize >>>
#37 2.247 # !! Contents within this block are managed by 'micromamba shell init' !!
#37 2.247 export MAMBA_EXE='/home/appuser/.local/bin/micromamba';
#37 2.247 export MAMBA_ROOT_PREFIX='/home/appuser/micromamba';
#37 2.247 __mamba_setup="$("$MAMBA_EXE" shell hook --shell bash --root-prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
#37 2.247 if [ $? -eq 0 ]; then
#37 2.247     eval "$__mamba_setup"
#37 2.247 else
#37 2.247     alias micromamba="$MAMBA_EXE"  # Fallback on help from micromamba activate
#37 2.247 fi
#37 2.247 unset __mamba_setup
#37 2.247 # <<< mamba initialize <<<
#37 2.247 
#37 2.256 Please restart your shell to activate micromamba or run the following:\n
#37 2.256   source ~/.bashrc (or ~/.zshrc, ~/.xonshrc, ~/.config/fish/config.fish, ...)
#37 DONE 2.6s

Here is the output of calling as non-root

  • micromamba : not-found error
  • ~/.local/bin/micromamba : works
#41 [37/68] RUN hash -r ;     source ~/.bashrc ;     micromamba info || /bin/true ;     ~/.local/bin/micromamba info
#41 0.647 /bin/bash: line 1: micromamba: command not found
#41 0.702 
#41 0.702        libmamba version : 2.0.2
#41 0.702      micromamba version : 2.0.2
#41 0.702            curl version : libcurl/8.10.1 OpenSSL/3.3.2 zlib/1.3.1 zstd/1.5.6 libssh2/1.11.0 nghttp2/1.58.0
#41 0.702      libarchive version : libarchive 3.7.4 zlib/1.2.13 bz2lib/1.0.8 libzstd/1.5.6
#41 0.702        envs directories : /home/appuser/micromamba/envs
#41 0.702           package cache : /home/appuser/micromamba/pkgs
#41 0.702                           /home/appuser/.mamba/pkgs
#41 0.702             environment : base
#41 0.702            env location : /home/appuser/micromamba
#41 0.702       user config files : /home/appuser/.mambarc
#41 0.702  populated config files : /home/appuser/.condarc
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions