Docker Community Forums

Share and learn in the Docker community.

Dockerfile referencing host OS files vs container files


(Frank) #1

I’m just starting to learn Docker so please forgive me if I ask some stupid questions. I have sat through a lot of John Wills webinar’s but nothing was really sinking in so decided to try to do my own little project.
Just trying to do something simple that seems to be somewhat of a natural fit with docker. I have a bunch of web services running on tomcat and want to basically create a container for each service. I think this should be pretty easy. But I would like to do it as my own container and own repository.

I can simple of course use someone else’s/official on on the hub repository of tomcat:
$docker run -it --rm -p 8888:8080 tomcat:7.0

Used that Dockerfile with
$docker build -t myrepo/tomcat
and ran with
$docker run -it --rm -p 8888:8080 myrepo/tomcat

still all is good.

Now I want to change tomcat files, namely tomcat-users.xml and server.xml to match my current tomcat setup. Now I see I can use maybe the -v option on the run line as found that in the fourm.

Ex: $docker run -it -d --name tomcat -v $HOME/tomcat/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml:ro -p 8888:8080 myrepo/tomcat

Ok I guess that’s ok but would not the correct way be to place this command to overlay the tomcat-users.xml and server.xml in the Dockerfile? If so how would you do that? I don’t see how you differentiate between a file in the container vs a file on the local system inside a Dockerfile. It seems to mainly refer to files in the container. Would think it would be a simple copy/overlay but can’t seem to figure out how to do it.


(Frank) #2

Sorry I found it, copy src dest. src being the host OS. miss read it first time.