Configuring Jersey Servlet Container on Embedded Tomcat

One of the ways of configuring a Jersey Servlet Container on Tomcat is via a web.xml file.
For example, typically the following web.xml file is used where a Servlet and its mappings are defined:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>  
<web-app xmlns=""  



When starting an embedded version of Tomcat the same Jersey Servlet that was defined in the XML file can be defined via code:

    RestApplication restApplication = new RestApplication();
    ServletContainer servletContainer = new ServletContainer(restApplication);
    Tomcat.addServlet(ctx, "api", servletContainer);
    ctx.addServletMapping("/api/*", "hubble-api");

There are three steps involved in configuring Jersey:

Printing Docker Container IP Address

Just wanted to share a smarcut to print a docker container IP address.

Add the following to your ~/.bashrc or ~/.bash_profile

docker-ip() {  
  docker inspect --format '{{ .NetworkSettings.IPAddress }}' "[email protected]"

After sourcing the file you can type on your sell docker-ip myContainerName and get back the IP address associated with the container:

$ docker-ip dnsdock  

Got the idea from a post on this stackoverflow thread.