I need to launch a background job (Google SQL Proxy) inside a Docker container (actually an AppEngine image).
After some struggle with it I discovered that trying to launch the background job either discards the job the moment I detach from container (see RUN command in script) or the container stops working properly (see CMD command in script)
Here is the Dockerfile:
FROM eu.gcr.io/google-appengine/ubuntu-php56
ADD ./run.sh /app
RUN chmod 777 /app/run.sh
#RUN nohup /app/run.sh & #This is lost the moment I finished creation of container
CMD nohup /app/run.sh & #This crash the container
Here is the run.sh file:
#!/bin/bash
while true
do
echo "Beep"
sleep 2
done
Here is the command to build the Docker image:
docker image build --tag red .
Here is the command to create the docker container:
docker run -d -p 8080:8080 --name red1 red
Here is how I connect to container to check what's inside
docker exec -it red1 /bin/bash
Once again my target is to be able to lunch and keep run.sh running all the time.