Adding Docker Volume to Dockerfile

Hii

I have created one volume in my host machine using ( docker volume create new_vol ) command now I want to add new_vol inside the Dockerfile how can I do this ?
ARG VERSION=latest

FROM tomcat:$VERSION

MAINTAINER dockerexpert
"
VOLUME ["/usr/local/tomcat/webapps"] (*What to do here? )
ENV role app
ENV env dev
ENV name chetu
EXPOSE 8080
CMD [“catalina.sh”, “run”]

~

My Dockerfile is looking like this now how to add my customized volume inside this Dockerfile?

The VOLUME instruction defines which target folders are ment to be volume targets.

When you run a container you need to map a volume against this folder; otherwise an anonymous volume (those with random letters and number) will be created for you.

1 Like

Ok Thanks for this so you meant to say that the volumes field that I defined in the Docker file is that for what I have to make it persistent for my container and when I run the docker command I need to attach my created volume with this path That I have defined in the Docker file ?

Could you rephrase your post? I am not sure if I understood you properly.

I tried and working thanks for ur response