I am trying to run /usr/sbin/init
in a shell script, but it never executes. I tried the solution mentioned here, but it did not work or maybe I am doing something wrong.
Error Message from container logs: Couldn't find an alternative telinit implementation to spawn.
Here is my Dockerfile
FROM centos
RUN yum install -y epel-release && \
yum install -y --nogpgcheck https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el7.noarch.rpm && \
yum update -y && \
yum install -y virt-what salt-master salt-api vim && \
yum clean all && \
rm -rf /var/cache/yum
COPY extras/netapi.conf /etc/salt/master.d/
COPY entrypoint-master.sh /entrypoint-master.sh
RUN yum -y install systemd; yum clean all; \
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i ==
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ “/sys/fs/cgroup” ]
EXPOSE 4505/tcp
EXPOSE 4506/tcp
EXPOSE 8080/tcp
CMD ["/entrypoint-master.sh"]
And here is my entrypoint
script
#!/bin/bash
set -e
/usr/sbin/init
# Start the first process
/usr/bin/salt-master -d -l debug
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start salt-master: $status"
exit $status
fi
# Start the second process
/usr/bin/salt-api -d -l debug
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start salt-api: $status"
exit $status
fi
# Naive check runs checks once a minute to see if either of the processes exited.
# This illustrates part of the heavy lifting you need to do if you want to run
# more than one service in a container. The container exits with an error
# if it detects that either of the processes has exited.
# Otherwise it loops forever, waking up every 60 seconds
while sleep 60; do
ps aux |grep salt-master |grep -q -v grep
PROCESS_1_STATUS=$?
ps aux |grep salt-api |grep -q -v grep
PROCESS_2_STATUS=$?
# If the greps above find anything, they exit with 0 status
# If they are not both 0, then something is wrong
if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 ]; then
echo "One of the processes has already exited."
exit 1
fi
done
exec "$@"
Can someone please suggest how I can fix it. Thanks.