4
I created this image (https://hub.docker.com/r/keviocastro/elgg-docker/~/dockerfile/) setting up an environment for a social networking web application.
This application requires a link to a Mysql container.
In the Dockerfile of my image (https://github.com/keviocastro/elgg-docker/blob/master/2.0.0-beta.3/Dockerfile) there is a RUN command with a shell script that installs and configures the application, as the excerpt below:
COPY . /elgg-docker/
RUN chmod +x /elgg-docker/elgg-install.sh
RUN /elgg-docker/elgg-install.sh
In this shell script contains a chunk of code waiting for the mysql server to respond to continue the application installation:
#wait for mysql
i=0
while ! netcat $ELGG_DB_HOST $MYSQL_PORT >/dev/null 2>&1 < /dev/null; do
i=`expr $i + 1`
if [ $i -ge $MYSQL_LOOPS ]; then
echo "$(date) - ${ELGG_DB_HOST}:${MYSQL_PORT} still not reachable, giving up."
exit 0
fi
echo "$(date) - waiting for ${ELGG_DB_HOST}:${MYSQL_PORT}... $i/$MYSQL_LOOPS."
sleep 1
done
My problem is that when I compile the image with the command "Docker build -t keviocastro/Elgg-Docker ." The installation shell script runs, and in the snippet it checks if the mysql server is available returns error and then the image build is not completed.
As I can identify, in the shell script or some other solution, that the command that is running is Docker build and porting the chunk waiting for the mysql server does not need to be run?
you can put the Docker build command output?
– LeoCBS