On 01/09/2020 08:42, Paul wrote:
> Hi Chris,
>
> First of all tnx for your response.
>
> For my own purpose it was about the conf/[engine]/[host] folder and I'm
> now creating that in my dockerfile and thus I got rid of the error.
>
> However, this question is not so much to solve it for just myself, but
> more to be able to give proper directions to anyone dockerizing Tomcat
> or providing 'generic' Tomcat base images.
>
> I'm guessing whether or not to turn of createDirs really depends on how
> Tomcat is used to deploy webapps/war files and whether or not turning
> off createDirs will cause issues on startup/at runtime might depends on
> how hosts are defined (unpackWAR/autoDeploy/deployOnStartup settings),
> but the exact correlation is unclear to me and I cannot find any
> documentation on it.

createDirs was added so that directory creation was triggered early and
any associated errors occurred during start-up rather than at some point
later during an automatic deployment.

The directories are only required if:
a) Tomcat is configured to extract the context.xml file from a WAR
   and copy it to the defined xmlBase for the Host. This will only
   happen if copyXML is true (defaults to false) and deployXML is
   true.
or
b) You want to define Contexts (web applications) via external
   context.xml files

See http://tomcat.apache.org/tomcat-10.0-doc/config/host.html

> Which folders does Tomcat depend on for the deployment of WAR files
> then? The standard Tomcat download comes with the following:
>
> <Engine name="Catalina" defaultHost="localhost">
>       <Host name="localhost"  appBase="webapps"
>             unpackWARs="true" autoDeploy="true">
>
> And already has the webapps folder in the distribution.
>
> Am I correct in saying that createDirs="true" would make sure the
> /webapps

No.

> and /conf/Catalina/localhost directories exist on startup?

Yes.

> Or any other directory of you'd configure other engines/hosts?

No.

> And when does Tomcat utilize the conf/[engine]/[host] folder? As I
> mentioned before I resolved the error in the logs for my own purpose by
> just creating the missing directory while dockerizing my app, but afaics
> Tomcat never writes something to it, which makes me think that the
> folder is only used in certain circumstances.

See above. You can also place appropriately named context.xml files
there yourself.

See
http://tomcat.apache.org/tomcat-10.0-doc/config/host.html#Automatic_Application_Deployment

and

http://tomcat.apache.org/tomcat-10.0-doc/config/automatic-deployment.html

> Again: my goal is to get clear what Tomcat needs in different scenarios,
> thus things can be done correctly in generic Tomcat docker base images
> and/or provide proper instructions with those base images as to how
> (re)configure/adjust the base images based on the different usages.
>
> Maybe it'd make sense to add such clarifications to the Tomcat docs as
> well (I'd be willing to create a PR)
>
> TIA,
>
> Paul
>
>
> On 8/31/2020 5:24 PM, Christopher Schultz wrote:
> Paul,
> 
> On 8/31/20 05:36, Paul wrote:
>>>> Hello,
>>>>
>>>> When running Tomcat in a Docker container as non-root, I'm getting
>>>> an error entry in the logs:
>>>>
>>>> Unable to create directory for deployment:
>>>> [/usr/local/tomcat/conf/Catalina/localhost] I traced this down to
>>>> the aforementioned directory not being there when Tomcat gets
>>>> launched and the user running Tomcat does not having the
>>>> permissions to create the directory.
>>>>
>>>> I also traced where this error message is coming from and its due
>>>> to the createDirs attribute on the host declaration in server.xml
>>>> not being set to false. The docs for the createDirs property states
>>>> that if its set to true (the default) it'll attempt to create some
>>>> directories, log an error when it fails, but the failure wont stop
>>>> the startup of Tomcat.
>>>>
>>>> But what I cannot find anywhere is why those directories are
>>>> created in the first place and what the ramifications are of them
>>>> not being created when createDirs is set to false.
> You are deploying a WAR file, right?
> 
> If you don't set createDirs="true" then Tomcat will not be able to
> unpack WAR files for you.
> 
>>>> This question is for Tomcat docker images in general (in order to
>>>> determine whether generic Tomcat Docker images should do something
>>>> different to prevent these Errors in the logs), in my specific
>>>> scenario however I'm running one webapp: an exploded WAR in the
>>>> webapps/ROOT directory, which comes with its on context.xml in
>>>> /webapps/ROOT/META-INF/context.xml
> If webapps/ already exists, what directory is Tomcat trying to create?
> conf/[engine]/[host]?
> 
> Can you arrange for conf/[engine]/[host] (usually
> conf/Catalina/localhost) to exist so that the setting for createDirs
> doesn't matter?
> 
> -chris
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to