Hi all, i guess i solved the mystery around the problem. I took a look at scoots yml file and saw something that got me thinking and i changed it accordingly in my file. I had the property container-name set and i removed it. Then i changed my uri to use the service name and rebuild my images. After that the connection started working as expected.
Conclusion: Dont set a container-name in the docker-compose file. Cheers Markus Am Do., 4. Mai 2023 um 07:55 Uhr schrieb Markus Rosjat < [email protected]>: > hey jun, > > my yml file: > > version: '3' > services: > trac: > build: > context: . > dockerfile: trac.Dockerfile > container_name: trac > command: tracd --auth="*,/var/trac/auth/tracauth,testtrac" -p8000 > --base-path=/testtrac -s /var/trac/projects/testtrac > ports: > - 8000:8000 > volumes: > - .:/var/trac > depends_on: > - postgresql > networks: > - trac-network > > postgresql: > build: > context: . > dockerfile: postgresql.Dockerfile > container_name: trac-postgresql > ports: > - 5432:5432 > restart: always > environment: > POSTGRES_PASSWORD: secret > networks: > - trac-network > networks: > trac-network: > > my test script again that can query the db in the postgresql container > > import psycopg2 > > conn = psycopg2.connect("postgres://dbuser:dbpassword@trac-postresql > :5432/trac_db") > cur = conn.cursor() > cur.execute("SELECT * FROM ticket;") > rows = cur.fetchall() > for row in rows: > print(row) > using localhost, well i dont see how this will work even docker handles 2 > containers as 2 different machines but for the sake of argument i changed > my trac.ini back an got the expected result. With localhost in the uri > I am back at the point that trac cant reach the db container. > > cheers > > MArkus > > Am Do., 4. Mai 2023 um 03:20 Uhr schrieb Jun Omae <[email protected]>: > >> On Wed, May 3, 2023 at 9:44 PM Markus Rosjat <[email protected]> >> wrote: >> > >> > hi all, >> > >> > i try to play around a little and hit a bump in the road with using 2 >> containers formy setup. I got one container for trac and one container for >> postgresql. >> >> You should share your docker-compose.yml if you want advice and supports. >> >> > So far so good, if i try to connect with python from trac container to >> the postgresql one i can query data as expected >> >> How did you execute query to verify it? Please provide commands which you >> tried. >> >> > but if i try to run tracd it tells me it can connect to the db ... here >> is my pseudo connection string in my trac.ini >> > >> > database = postgres://dbuser:dbpassword@dockercontainer:5432/tracdb >> >> Try to use "localhost" instead of "dockercontainer". >> >> >> -- >> Jun Omae <[email protected]> (大前 潤) >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Trac Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/trac-users/CAEVLMagL3AQJVvFov6dUPwCsRgBmi1WCg-ysqxL3SFoE%3Dj5ieg%40mail.gmail.com >> . >> > -- You received this message because you are subscribed to the Google Groups "Trac Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAJ4osOnfpRPcnJAmj%2Bvd_K7e3%2BGK-oxu-NzhxUe2e7YYdqJ1JQ%40mail.gmail.com.
