Reputation: 3041
I have an existential question about docker. Given this dockerfile:
FROM someImage
MAINTAINER abc
ENV something=somehow
RUN sh calculatePi.sh
ENV somethingElse=somehow2
"Calculate Pi" is a "continuous" program that never ends and needs to be ran on the background. It calculates all the digits of PI (3.1415.....) and save it to a txt file.
My question:
Upvotes: 0
Views: 80
Reputation: 31
May be you can write your docker file like this:
FROM someImage
MAINTAINER abc
ENV something=somehow
ENV somethingElse=somehow2
ENTRYPOINT ["/bin/bash"]
CMD ["calculatePi.sh"]
Then when you run this image
docker run -d thisImage
The script calculatePi.sh will run in your container as an App.
Upvotes: 1
Reputation: 57460
No, that Dockerfile won't work. RUN
instructions need to complete before Docker can create an image from them. Perhaps you want to make that a CMD
instruction instead?
Upvotes: 1
Reputation: 19144
When Docker builds an image, each instruction in the Dockerfile gets executed in an interim container, run from the preceding image layer. So if your calculatePi.sh
ran endlessly then your image would never build - it would stick at the RUN
instruction waiting for it to complete.
In practice, it's more likely that you'll max out disk or CPU resource and take down the machine if you tried to build it. Either way, you wouldn't get a completed image that you could run.
Upvotes: 1