Is there is any option for defining resource limitation in Dockerfile?
then how to define already created volume for specific folder in container ??
I cannot using my volumes in Dockerfile , it creates new volumes with random id for each run
Resource limitations in the Dockerfile: no. The Dockerfile defines the steps for building the image; resource constraints are applied when you run a container from the image.
You can create volumes which contain data in the image - but you need to create the files first and then expose the volume. Build from this Dockerfile:
FROM ubuntu
RUN mkdir -p /var/app && echo 'saved' > /var/app/file1
VOLUME /var/app
RUN mkdir -p /var/app && echo 'not saved' > /var/app/file2
And the image will contain file1
but not file2
:
> docker run --rm temp ls /var/app
file1
For the reason, see the answer to this question.