#community-help

Docker Compose Issue with Connecting Server and Typesense

TLDR Priyank couldn't connect their server with typesense through Docker compose. After troubleshooting with Kishore Nallan and WL, user discovered that they needed to specify the IP address of the typesense service in their client configuration.

Powered by Struct AI
+11
10
7mo
Solved
Join the chat
Feb 02, 2023 (7 months ago)
Priyank
Photo of md5-a9a351e11d64f05b41fec183816a0cda
Priyank
06:57 AM
I am using docker compose to run my server and typsense side by side but for some reason my server in container is not able to connect with typesense. please can anyone help me ?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
07:13 AM
Did you expose port 8108 for docker?
Priyank
Photo of md5-a9a351e11d64f05b41fec183816a0cda
Priyank
07:19 AM
actually i am kind of new to this docker ecosystem this is my compose config please check if there's any error
07:19
Priyank
07:19 AM
version: "3"
services:
typesense:
image: typesense/typesense:0.22.2
command: "--data-dir /data --api-key=ecommerce"
ports:
- "8108:8108"
volumes:
- typesense-data:/data
expose:
- "8108"

node-app:
depends_on:
- typesense
build: .
ports:
- "8000:8000"
environment:
- PORT=8000

volumes:
typesense-data:
driver: local
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
07:25 AM
Check if the volume directory used typesense-data actually exists. You can also check the container logs to see if Typesense actually starts.
Priyank
Photo of md5-a9a351e11d64f05b41fec183816a0cda
Priyank
09:12 AM
yeah i checked typesense starts fine but my nodejs server is not able to connect to it
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:33 AM
This is likely a Docker compose configuration issue. I'm not super familiar with that, so you can probably get better help on Stackoverflow.
WL
Photo of md5-e18fd6bf1ed8f3adba05f7061edef1e1
WL
10:09 AM
The enable-cors flag needs to be specified so that the server can be called from a frontend?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:13 AM
Yes but it's enabled by default
Priyank
Photo of md5-a9a351e11d64f05b41fec183816a0cda
Priyank
10:24 AM
i figured it out ! in case of docker compose you have to specify ip address of typesense service in typesense client configuration in nodejs server
+11