I am trying to install cryosparc v4.2.1 inside a docker file and I am facing trouble with the fact that the install.sh script is trying to ping the host when being called, which is a problem when trying to run into a Dockerfile. Indeed the Dockerfile itself alone isn’t able to ping the container before being built, which means one has to patch the install.sh before using it to remove the ping lines.
Would it be possible to add an option to it, to avoid the ping function?
I would suggest this:
# install.sh
ENABLE_DB_AUTH=true
PING_MASTER_HOSTNAME=true
--disable_db_auth)
ENABLE_DB_AUTH=false
shift
shift
;;
--disable_ping)
PING_MASTER_HOSTNAME=false
shift
;;
*) # unknown option
echo "Unknown option: $key"
exit 1
#################################################
# CHECK HOSTNAME
#################################################
if [[ "$PING_MASTER_HOSTNAME" == "true" ]]; then
if ! ping -c 4 "$MASTER_HOSTNAME" > /dev/null ; then
echo "Error: Could not ping $MASTER_HOSTNAME"
exit 1
fi
fi
Welcome to the forum @Elsa.
There may be other ways of avoiding a conflict between the ping command and your deployment plan. Would you like to illustrate your plan by posting your Dockerfile draft, with confidential information concealed?
# syntax=docker/dockerfile:1.2
FROM docker.io/nvidia/cuda:11.8.0-devel-ubuntu22.04
# gracefully kill the container
STOPSIGNAL SIGRTMIN+3
ENV DEBIAN_FRONTEND noninteractive
# notify systemd that we are in a container
ENV container docker
# munge and slurm stuff
ARG MUNGEUSER=983
ARG MUNGEGROUP=983
ARG SLURMUSER=120
ARG SLURMGROUP=120
RUN groupadd -f -g $SLURMGROUP slurm \
&& useradd -m -c "SLURM workload manager" -d /var/lib/slurm -u $SLURMUSER -g slurm -s /bin/bash slurm
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
zip unzip \
python2 \
python3 \
python3-dev \
python3-setuptools \
python3-pip \
libtiff5 \
netbase \
ed \
curl \
iputils-ping \
sudo \
net-tools \
openssh-server \
jq \
slurmd \
nodejs \
systemd \
&& rm -rf /var/lib/apt/lists/*
RUN groupmod -o -g $MUNGEGROUP munge \
&& usermod -c "MUNGE Uid 'N' Gid Emporium" -d /var/lib/munge -u $MUNGEUSER -g munge -s /sbin/nologin munge \
&& mkdir -p /var/log/munge \
&& chown -R munge:$MUNGEGROUP /etc/munge /var/log/munge
ENV CRYOSPARC_ROOT_DIR /app
RUN mkdir -p ${CRYOSPARC_ROOT_DIR}
WORKDIR ${CRYOSPARC_ROOT_DIR}
ARG CRYOSPARC_VERSION={{ cryosparc_version }}
ENV CRYOSPARC_VERSION=${CRYOSPARC_VERSION}
# install master
ENV CRYOSPARC_MASTER_DIR ${CRYOSPARC_ROOT_DIR}/cryosparc_master
COPY cryosparc_master ${CRYOSPARC_MASTER_DIR}
RUN cd ${CRYOSPARC_MASTER_DIR} \
&& bash ./install.sh --license {{ cryosparc_license_id }} --hostname \
{{ cryosparc_host_basename }}-0.{{ cryosparc_host_service }}.{{ cryosparc_k8s_namespace }}.svc.{{ cryosparc_cluster_name }} \
--yes --allowroot --port {{ cryosparc_port }} && mkdir run
COPY --chown=root:root ./cryosparc_master.service /usr/lib/systemd/system/
COPY --chown=root:root ./journal-out.service /usr/lib/systemd/system/
COPY --chown=$SLURMUSER:$SLURMGROUP ./slurmd /etc/default/slurmd
RUN mkdir /etc/systemd/system/slurmd.service.d/ && echo "[Unit]\nConditionPathExists=" > /etc/systemd/system/slurmd.service.d/overrides.conf
COPY --chown=munge:$MUNGEGROUP ./munge.key /etc/munge/munge.key
RUN systemctl enable munge.service \
journal-out.service \
slurmd.service \
cryosparc_master.service
# No need for graphical.target here
RUN systemctl set-default multi-user.target
# By default run systemd-init process (requires TTY creation permission)
CMD ["/usr/lib/systemd/systemd", "--system"]
EXPOSE 45000
This works on Kubernetes now, thus setting the hostname as it would be on Kubernetes. But since I am not on the pods when building the container I still need to stop the ping from happening.
Thanks for sharing that @Elsa . Could you alternatively run install.sh outside the container, then COPY the complete installation from the build context, possibly followed by some modifications of cryosparc_master/config.sh, cryosparc_worker/config.sh inside the container? The absolute paths would have to match between cryosparc_master/, cryosparc_worker/ outside and inside the container.