Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spawn service in parallel with bash script #2071

Open
robingarcia opened this issue Mar 6, 2024 · 4 comments
Open

Spawn service in parallel with bash script #2071

robingarcia opened this issue Mar 6, 2024 · 4 comments

Comments

@robingarcia
Copy link

robingarcia commented Mar 6, 2024

Version of Apptainer

What version of Apptainer (or Singularity) are you using? Run

apptainer --version (or singularity --version).

We are running apptainer version 1.2.5-1.el8

Expected behavior

Run the default entrypoint of the PostgreSQL apptainer container additionally to my own command/bash script.

apptainer exec -B pgdata:/var/lib/postgresql/data -B pgrun:/var/run/postgresql 
-e -C --env-file pg.env postgres_15-bookworm.sif pg_isready
/var/run/postgresql:5432 - accepting connections

or

apptainer exec -B pgdata:/var/lib/postgresql/data -B pgrun:/var/run/postgresql 
-e -C --env-file pg.env postgres_15-bookworm.sif process_fms_uploads.sh -h
/var/run/postgresql:5432 - accepting connections
            usage: popreport.sh [options]
                    -i <indir>       - Name of the incoming directory
                   -l <logfile>     - Name of the logfile
                  -u <user>        - user who runs the jobs
                  -g <group>       - group of user, who runs the jobs
                  -a <apiishome>   - value of APIIS_HOME
                  -p <project dir> - output directory

Actual behavior

Entrypoint is not executed but only the command "pg_isready" is executed and the entrypoint of the PostgreSQL service is apparently skipped.

apptainer exec -B pgdata:/var/lib/postgresql/data -B pgrun:/var/run/postgresql \
-e -C --env-file pg.env postgres_15-bookworm.sif pg_isready
/var/run/postgresql:5432 - no response

Steps to reproduce this behavior

apptainer pull docker://postgres:15-bookworm

cat >> pg.env <<EOF
export TZ=Europe/Berlin
export POSTGRES_USER=pguser
export POSTGRES_PASSWORD=mypguser123
export POSTGRES_DB=mydb
export POSTGRES_INITDB_ARGS="--encoding=UTF-8"
EOF

mkdir pgdata
mkdir pgrun
apptainer run  -B pgdata:/var/lib/postgresql/data -B pgrun:/var/run/postgresql -e -C --env-file pg.env postgres_15-bookworm.sif 

What OS/distro are you running

cat /etc/os-release 
NAME="CentOS Stream"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Stream 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"

How did you install Apptainer

yum info apptainer
Last metadata expiration check: 0:01:35 ago on Wed 06 Mar 2024 14:25:41 CET.
Installed Packages
Name         : apptainer
Version      : 1.2.5
Release      : 1.el8
Architecture : x86_64
Size         : 116 M
Source       : apptainer-1.2.5-1.el8.src.rpm
Repository   : @System
From repo    : epel
Summary      : Application and environment virtualization formerly known as Singularity
URL          : https://apptainer.org
License      : BSD and LBNL BSD and ASL 2.0
Description  : Apptainer provides functionality to make portable
             : containers that can be used across host environments.

@robingarcia
Copy link
Author

@GodloveD
Copy link
Contributor

GodloveD commented Mar 6, 2024

I'm a little confused because in the first examples above you are using the exec command but then in the steps to reproduce you are using the run command. The Docker entrypoint should be copied into the container runscript which only gets triggered by the run or instance run commands. So if you want the entrypoint to run, you should use one of those.

@brandonbiggs
Copy link

I was looking for something similar and stumbled upon this page. Maybe this will help someone else in the future - https://www.linuxwave.info/2022/04/running-postgresql-database-using.html

@DrDaveD
Copy link
Contributor

DrDaveD commented May 10, 2024

Alternatively you could probably have your own script invoke the runscript. That is, use exec to run your script and let it first call /singularity.d/runscript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants