I have a FreeBSD 10.1 machine. I want to install tomcat8 and openjdk8 in a jail. This jail will only be used for few web application, and I do not want to install the ports collection, nor the full pkg management tool in it. For another jail, I could install all required packages from the host with :

pkg -j jail_name install package_name

The problem is that the precompiled package for tomcat8 has a dependency on openjdk7 when one of my apps needs a jdk8.

I know it could be done by installing the port collection in the jail, opening firewalls to allow connections from the jail to the whole world, installing everything from ports and then reconfiguring everything and removing ports collection. But I'd rather not do all that !

So, how can I install tomcat8 over openjdk8 in a jail without installing the ports collection and allowing connections from the jail to the outside world ?


It can be done by mixing the port collection and the pkg tool, but it is a bit tricky.

1 Host part

First install openjdk8 as a package : pkg install openjdk8

Then build, install an generate package for tomcat8 from the ports. As openjdk8 is already installed, it will be used by the ports

cd /usr/ports/www/tomcat8
make build
make install
make package     # <= Ok the package is in work/pkg

During the build, jakarta-commons-daemon-1.0.15 as been built with a dependence on openjdk8 : just build the package for it too :

cd /usr/ports/devel/jakarta-commons-daemon
make package     # <= Ok the package is in work/pkg

2 Jail part

Now the packages have been built, we can use them with pkg -j jail_name add. The tricky part is that even if the command is started from the host, the path is relative to the jail root !

So assuming that the jail filesystem is accessible through /usr/jail/jail_name :

cp /usr/ports/www/tomcat8/ports/pkg/tomcat*.pkg /usr/jails/jail_name/root
cp /usr/ports/devel/jakarta-commons-daemon/ports/pkg/jakarta*.pkg /usr/jails/jail_name/root

Depending on how the jail is configured, you may have to scp the files

It is now trivial :

pkg -j jail_name add /root/jakarta-commons-daemon-1.0.15.txz
pkg -j jail_name add /root/tomcat8-8.0.18.txz

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.