Mailing List Archive

running trac in docker containers
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. So far so good, if i try to connect with python from trac
container to the postgresql one i can query data as expected 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

as i said if i pass that to psycopg2.connect as proper args i can get a
cursor and fetch data. If i try to do it with trac i get

Trac Error

TracError: Unable to check for upgrade of trac.db.api.DatabaseManager:
TimeoutError: Unable to get database connection within 10 seconds.

So any pointers here would be nice.

cheers

MArkus

--
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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAJ4osOmrN6-LrkC1OzDYRXf%3DK7DQnwD6N237E9JWn_GKmwaJtQ%40mail.gmail.com.
Re: running trac in docker containers [ In reply to ]
I did it with mysql, but used a docker-compose file to create a network and
make sure both containers shared the same network:
version: "3"
services:

TracDB:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: pass
MYSQL_DATABASE: trac
MYSQL_USER: tracuser
MYSQL_PASSWORD: pass
ports:
- "3306:3306"
command: --character-set-server=utf8 --collation-server=utf8_bin
networks:
- TracNet

Trac:
image: <your docker repos>/trac:latest
restart: always
volumes:
# Mount the data migrated here after'trac-admin /var/trac/ hotcopy
/home/ubuntu/TracBackup':
- /home/ec2-user/Trac/TracBackup/:/var/trac/<sitename>/
#Had to migrate to MySQL, so 1st launch of trac container had to run this
command line
# command : sh -c "sleep 5 && trac-admin /var/trac/<sitename>/ convert_db
"mysql://tracuser:password@TracDB:3306/trac"
ports:
- "8088:80"
depends_on:
- TracDB
networks:
- TracNet

networks:
TracNet:

On Wednesday, May 3, 2023 at 7:44:29?AM UTC-5 Markus Rosjat 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. So far so good, if i try to connect with python from trac
> container to the postgresql one i can query data as expected 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
>
> as i said if i pass that to psycopg2.connect as proper args i can get a
> cursor and fetch data. If i try to do it with trac i get
>
> Trac Error
>
> TracError: Unable to check for upgrade of trac.db.api.DatabaseManager: TimeoutError: Unable to get database connection within 10 seconds.
>
> So any pointers here would be nice.
>
> cheers
>
> MArkus
>

--
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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/d047a9c0-cdb5-48be-a18c-3ea650cc3f47n%40googlegroups.com.
Re: Re: running trac in docker containers [ In reply to ]
hey scott,

i have a docker compose file but my tracd command doesnt seems to work, if
i run int with -d flag the container restarts all the time.
Do i run the tracd command without it i get the line i posted so i am stuck
at the point where both container work, i can access the db from trac
container over simply python but running tracd doesnt seem to like the
connection

cheers

Markus

Am Mi., 3. Mai 2023 um 19:27 Uhr schrieb Scott Dunt <sddunt@gmail.com>:

> I did it with mysql, but used a docker-compose file to create a network
> and make sure both containers shared the same network:
> version: "3"
> services:
>
> TracDB:
> image: mysql:5.7
> restart: always
> environment:
> MYSQL_ROOT_PASSWORD: pass
> MYSQL_DATABASE: trac
> MYSQL_USER: tracuser
> MYSQL_PASSWORD: pass
> ports:
> - "3306:3306"
> command: --character-set-server=utf8 --collation-server=utf8_bin
> networks:
> - TracNet
>
> Trac:
> image: <your docker repos>/trac:latest
> restart: always
> volumes:
> # Mount the data migrated here after'trac-admin /var/trac/ hotcopy
> /home/ubuntu/TracBackup':
> - /home/ec2-user/Trac/TracBackup/:/var/trac/<sitename>/
> #Had to migrate to MySQL, so 1st launch of trac container had to run this
> command line
> # command : sh -c "sleep 5 && trac-admin /var/trac/<sitename>/ convert_db
> "mysql://tracuser:password@TracDB:3306/trac"
> ports:
> - "8088:80"
> depends_on:
> - TracDB
> networks:
> - TracNet
>
> networks:
> TracNet:
>
> On Wednesday, May 3, 2023 at 7:44:29?AM UTC-5 Markus Rosjat 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. So far so good, if i try to connect with python from trac
>> container to the postgresql one i can query data as expected 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
>>
>> as i said if i pass that to psycopg2.connect as proper args i can get a
>> cursor and fetch data. If i try to do it with trac i get
>>
>> Trac Error
>>
>> TracError: Unable to check for upgrade of trac.db.api.DatabaseManager: TimeoutError: Unable to get database connection within 10 seconds.
>>
>> So any pointers here would be nice.
>>
>> cheers
>>
>> MArkus
>>
> --
> 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 trac-users+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/trac-users/d047a9c0-cdb5-48be-a18c-3ea650cc3f47n%40googlegroups.com
> <https://groups.google.com/d/msgid/trac-users/d047a9c0-cdb5-48be-a18c-3ea650cc3f47n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

--
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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAJ4osOnOgofH-WVtNxruTxSgH9OZfhw0Xh%3DXacz%2BF2fC%3D%3DbMzw%40mail.gmail.com.
Re: Re: running trac in docker containers [ In reply to ]
hi all,

so i got one step further and my docker setup is serving my trac instance
now but it doesnt really solve the underlaying problem :(

so what i did is

- figure out the ip of the container
- changed my uri string in traci.ini so it uses the ip and not the docker
container name

at this point my data started to get loaded but as i said this doesnt solve
the problem, i want to be able to use a hostname for obvious reasons.
So how do i make trac aware that it needs to resolve my container name
correctly? I mean for my simply testscript its not a problem but trac cant
do it,
i hope we get something to work here.

here is my simply script that works just as expected ...

import psycopg2

conn = psycopg2.connect(
"postgres://dbuser:dbpassword@trac-postgresql:5432/trac_db"
)
cur = conn.cursor()
cur.execute("SELECT * FROM ticket;")
rows = cur.fetchall()
for row in rows:
print(row)

cheers

MArkus

Am Mi., 3. Mai 2023 um 19:55 Uhr schrieb Markus Rosjat <
markus.rosjat@gmail.com>:

> hey scott,
>
> i have a docker compose file but my tracd command doesnt seems to work,
> if i run int with -d flag the container restarts all the time.
> Do i run the tracd command without it i get the line i posted so i am
> stuck at the point where both container work, i can access the db from trac
> container over simply python but running tracd doesnt seem to like the
> connection
>
> cheers
>
> Markus
>
> Am Mi., 3. Mai 2023 um 19:27 Uhr schrieb Scott Dunt <sddunt@gmail.com>:
>
>> I did it with mysql, but used a docker-compose file to create a network
>> and make sure both containers shared the same network:
>> version: "3"
>> services:
>>
>> TracDB:
>> image: mysql:5.7
>> restart: always
>> environment:
>> MYSQL_ROOT_PASSWORD: pass
>> MYSQL_DATABASE: trac
>> MYSQL_USER: tracuser
>> MYSQL_PASSWORD: pass
>> ports:
>> - "3306:3306"
>> command: --character-set-server=utf8 --collation-server=utf8_bin
>> networks:
>> - TracNet
>>
>> Trac:
>> image: <your docker repos>/trac:latest
>> restart: always
>> volumes:
>> # Mount the data migrated here after'trac-admin /var/trac/ hotcopy
>> /home/ubuntu/TracBackup':
>> - /home/ec2-user/Trac/TracBackup/:/var/trac/<sitename>/
>> #Had to migrate to MySQL, so 1st launch of trac container had to run this
>> command line
>> # command : sh -c "sleep 5 && trac-admin /var/trac/<sitename>/ convert_db
>> "mysql://tracuser:password@TracDB:3306/trac"
>> ports:
>> - "8088:80"
>> depends_on:
>> - TracDB
>> networks:
>> - TracNet
>>
>> networks:
>> TracNet:
>>
>> On Wednesday, May 3, 2023 at 7:44:29?AM UTC-5 Markus Rosjat 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. So far so good, if i try to connect with python from trac
>>> container to the postgresql one i can query data as expected 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
>>>
>>> as i said if i pass that to psycopg2.connect as proper args i can get a
>>> cursor and fetch data. If i try to do it with trac i get
>>>
>>> Trac Error
>>>
>>> TracError: Unable to check for upgrade of trac.db.api.DatabaseManager: TimeoutError: Unable to get database connection within 10 seconds.
>>>
>>> So any pointers here would be nice.
>>>
>>> cheers
>>>
>>> MArkus
>>>
>> --
>> 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 trac-users+unsubscribe@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/trac-users/d047a9c0-cdb5-48be-a18c-3ea650cc3f47n%40googlegroups.com
>> <https://groups.google.com/d/msgid/trac-users/d047a9c0-cdb5-48be-a18c-3ea650cc3f47n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

--
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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAJ4osOkvMBMECtqPzHnD%3DogyG8ta-OnvJn4dwKgivR-sh8O0Vg%40mail.gmail.com.
Re: running trac in docker containers [ In reply to ]
On Wed, May 3, 2023 at 9:44?PM Markus Rosjat <markus.rosjat@gmail.com> 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 <jun66j5@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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAEVLMagL3AQJVvFov6dUPwCsRgBmi1WCg-ysqxL3SFoE%3Dj5ieg%40mail.gmail.com.
Re: running trac in docker containers [ In reply to ]
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 <jun66j5@gmail.com>:

> On Wed, May 3, 2023 at 9:44?PM Markus Rosjat <markus.rosjat@gmail.com>
> 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 <jun66j5@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 trac-users+unsubscribe@googlegroups.com.
> 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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAJ4osO%3DtrqpPYEEG1SpR1xYYhqYQ%3Ddn7RsZPXNtMQop%2BW18eYw%40mail.gmail.com.
Re: running trac in docker containers [ In reply to ]
hi all,

on last question about the whole setup. I use command to start tracd in
foreground since otherwise the container would quit if i run it with -d
flag.
So is this ok to do or should i try to work somehow around this and put
tracd in the background ?

cheer

Markus

Am Do., 4. Mai 2023 um 07:55 Uhr schrieb Markus Rosjat <
markus.rosjat@gmail.com>:

> 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 <jun66j5@gmail.com>:
>
>> On Wed, May 3, 2023 at 9:44?PM Markus Rosjat <markus.rosjat@gmail.com>
>> 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 <jun66j5@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 trac-users+unsubscribe@googlegroups.com.
>> 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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAJ4osOn7VySBoR76c%2BZR1J3iw8ZQMKF94UGYUGGdHEz2Mq44fA%40mail.gmail.com.
Re: running trac in docker containers [ In reply to ]
On Fri, May 5, 2023 at 10:42?PM Markus Rosjat <markus.rosjat@gmail.com> wrote:
>
> hi all,
>
> on last question about the whole setup. I use command to start tracd in foreground since otherwise the container would quit if i run it with -d flag.
> So is this ok to do or should i try to work somehow around this and put tracd in the background ?
>
> cheer
>
> Markus

I'm not sure what you're worried about, but I think tracd in foreground is okay.
However, I'd use apache + mod_wsgi rather than tracd in the first place.


--
Jun Omae <jun66j5@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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAEVLMaiMwe379LJugg0S%2BUSTQ0c%3DdD014et9vByGng1_Y_ia0Q%40mail.gmail.com.
Re: running trac in docker containers [ In reply to ]
I am not worried just wondering, I run an Apache as webserver at the moment
and do,rewrites to the tracd.

Jun Omae <jun66j5@gmail.com> schrieb am Fr., 5. Mai 2023, 16:13:

> On Fri, May 5, 2023 at 10:42?PM Markus Rosjat <markus.rosjat@gmail.com>
> wrote:
> >
> > hi all,
> >
> > on last question about the whole setup. I use command to start tracd in
> foreground since otherwise the container would quit if i run it with -d
> flag.
> > So is this ok to do or should i try to work somehow around this and put
> tracd in the background ?
> >
> > cheer
> >
> > Markus
>
> I'm not sure what you're worried about, but I think tracd in foreground is
> okay.
> However, I'd use apache + mod_wsgi rather than tracd in the first place.
>
>
> --
> Jun Omae <jun66j5@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 trac-users+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/trac-users/CAEVLMaiMwe379LJugg0S%2BUSTQ0c%3DdD014et9vByGng1_Y_ia0Q%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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAJ4osO%3DqhHiVaPFwJHsdV0ZaWYHzJoxyVNUu_gYhUm6XjEvy3w%40mail.gmail.com.