How to make Ontop listen on a different port than 8080 inside Docker

40 views
Skip to first unread message

André Teege

unread,
Apr 11, 2024, 8:06:54 AM4/11/24
to ontop4obda
Hi,
I am using Ontop as a Docker container to access a virtual SPARQL endpoint. I have another application (Metaphactory) in the same Docker network which successfully accesses this endpoint via <http://ontop-sparql:8080/sparql>.

Now, the default setup for Ontop listens on port 8080, but I need to configure additional endpoints to listen on different ports like 8081, 8082, etc., because I want to access multiple VKGs for different purposes.

How can I set up Ontop to listen on a port other than the default 8080 within its Docker container? Thanks for any help or best practices.

Benjamin Cogrel

unread,
Apr 11, 2024, 9:07:51 AM4/11/24
to André Teege, ontop4obda
Hi André,

For the multiple endpoints listening on different ports, do you intend to use different Docker containers?

If so, what about mapping the port 8080 of each container to a different exposed port in Docker compose?
Something like
  ports:
      - "8081:8080"
  [...]
  ports:
      - "8082:8080"
etc.

In the past the port used to be configurable using an environment variable, but it doesn't seem to be the case anymore (looking at the documentation).

Please let me know if the solution I proposed works for you.

Best,
Benjamin

--
Please follow our guidelines on how to report a bug https://ontop-vkg.org/community/contributing/bug-report
---
You received this message because you are subscribed to the Google Groups "ontop4obda" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ontop4obda+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ontop4obda/0c4681e0-65a4-4d92-845a-9035550dda32n%40googlegroups.com.

André Teege

unread,
Apr 11, 2024, 10:56:32 AM4/11/24
to ontop4obda
Hi Benjamin,

Thanks for the fast reply. Yes, I intend to use multiple Docker containers, one for each SPARQL endpoint. My setup is that I run one container with port mapping "8080:8080" and the second with  "8082:8080". Then I am able to access the endpoints from <http://localhost:8080/> and <http://localhost:8082/> from outside the container (e.g., via my browser).

However, I want (or rather my application) to access both endpoints internally within the same Docker network (my Metaphactory instance is deployed in a Docker container and shall access multiple virtual SPARQL endpoints as repositories).

As far as I understand, the port mappings do not affect which port the Ontop Docker application inside the container listens to. The application's listening port is determined by its own configuration. If Ontop is configured to listen on port 8080, changing the Docker port mapping to "8082:8082" wouldn't make Ontop listen on port 8082 unless Ontop itself is reconfigured to listen on this new port. So I am wondering how I can achieve this. Or do I oversee something?

Best, André

André Teege

unread,
Apr 11, 2024, 11:00:13 AM4/11/24
to ontop4obda
So, my Docker application can access <http://ontop-sparql:8080/sparql> internally for the first endpoint, but then the second endpoint would be the same unless I change it to be listening to another port internally and not just the mapping outside.

André Teege

unread,
Apr 11, 2024, 11:54:01 AM4/11/24
to ontop4obda
What I can actually do is access the externalized endpoint from within the Docker application via <http://host.docker.internal:8082> but in terms of security/network isolation I would prefer to change Ontop's listening port and let my application and Ontop endpoints communicate only inside a specified Docker network. So ideally, I wouldn't publish/map any port ...

Martynas Jusevičius

unread,
Apr 11, 2024, 12:47:18 PM4/11/24
to André Teege, ontop4obda
The second endpoint would have a different hostname? In docker-compose it’s based on the service name by default.

Benjamin Cogrel

unread,
Apr 12, 2024, 2:08:53 AM4/12/24
to André Teege, ontop4obda, Martynas Jusevičius
Hi,

I agree with Martynas. Instead of using different ports using different hostnames (one per container) should do the job.
 Something like 

where ontop-sparql1 and ontop-sparql2 are the names of the two containers/services.

See for example https://github.com/noi-techpark/it.bz.opendatahub.sparql/blob/main/docker-compose.yml where we had two Ontop endpoints (one guest, one with restricted access) in the same (default) network with a reverse proxy above.

Best,
Benjamin


André Teege

unread,
Apr 12, 2024, 7:26:44 AM4/12/24
to ontop4obda
Thanks guys, you're right, I don't need different ports (which seems so obvious now). I actually didn't realize this in the beginning because I used an underscore in the second Ontop container name (and consequently in the endpoint URL), which then caused an error in the hostname resolution, so it didn't work and I suspected the problem elsewhere ...
Have a nice weekend!
Reply all
Reply to author
Forward
0 new messages