Hi everyone,
I’m new to the docker world.
I’m using the tryton/tryton:4.8 containers and tryton-postgres for testing.
I have some questions:
is it possible to make a pg_restore on the tryton-postgres container so that it can restore an already populated database? How should to manage the owners?
in the tryton/tryton:4.8 container can I insert custom modules instead of the standard modules?
docker exec is you friend here (permit to launch a comand inside the contaner). You only need to have the db dumb accessible tot he container (by mounting a volume with the dump in it, or wget/curl/scp it inside). Then you can use a command like this:
docker exec -it containername /bin/bash
This will drop you in an interactive shell (so you dump and restore manually), but you can substitute the /bin/bash with any command you want.
You have two option here:
temporary (you need to do it every time, just for testing)
permanent (a better way IMHO)
temporary solution
You can just exec inside the running tryton container via:
docker exec -it containername /bin/bash
then install your module manually, or via pip.
Then update the database via the the classic
trytond-admin -u module --activate-dependencies #non the exact command
You should see the module after you refresh the tryton client.
permanent solution
The better solution is to create a new docker image, but based on the tryton docker container, thi by creating a new Dockerfile
(DISCAIMER: didn’t test it… but the concept should work)
FROM tryton/tryton:5.2 #change 5.2 if you want another version
RUN pip3 install mymoduleifonpypy==versionofthemodule
# you can install the module with pip3 install git+/hg+ if in a accesible version control
# otherwise you can COPY the custom module in the site-package/tryton/module folder
# or you can COPY the module folder and install it
# with RUN cd modulename && python3 setup.py install
EXPOSE 8000
VOLUME ["/var/lib/trytond/db"]
ENV TRYTOND_CONFIG=/etc/trytond.conf
USER trytond
then you need to build the image with docker build:
docker build . -t nameofmyimage:version
# were `.` is the path of the folder containing the Dockerfile you created
# where -t indicate the name of your image (-t is for tag)
if sucessfull, you can launch and configure it like the official one [documentation page].
Remember to substitute tryton/tryton with the name you indicated with -t of your new image.
!REMEMBER! the image you create with docker build is local to your computer, if you need to share it, you can push it to a docker registry.
If I launch tryton web I get the following error message:
Traceback (most recent call last):
File “/usr/local/lib/python35/dist-packages/trytond/wsgipy”, line 71, in dispatch_request
return endpoint(request, **requestview_args)
File “/usr/local/lib/python35/dist-packages/trytond/protocols/dispatcherpy”, line 41, in rpc
request, database_name, *requestrpc_params)
File “/usr/local/lib/python35/dist-packages/trytond/protocols/dispatcherpy”, line 58, in login
database_name, user, parameters, context=context)
File “/usr/local/lib/python35/dist-packages/trytond/securitypy”, line 31, in login
pool = _get_pool(dbname)
File “/usr/local/lib/python35/dist-packages/trytond/securitypy”, line 18, in _get_pool
poolinit()
File “/usr/local/lib/python35/dist-packages/trytond/poolpy”, line 161, in init
lang=lang, installdeps=installdeps)
File “/usr/local/lib/python35/dist-packages/trytond/modules/__init__py”, line 472, in load_modules
_load_modules(update)
File “/usr/local/lib/python35/dist-packages/trytond/modules/__init__py”, line 431, in _load_modules
graph = create_graph(module_list)[0]
File “/usr/local/lib/python35/dist-packages/trytond/modules/__init__py”, line 158, in create_graph
info = get_module_info(module)
File “/usr/local/lib/python35/dist-packages/trytond/modules/__init__py”, line 142, in get_module_info
with toolsfile_open(ospathjoin(name, ‘trytoncfg’)) as fp:
File “/usr/local/lib/python35/dist-packages/trytond/tools/miscpy”, line 78, in file_open
raise IOError('File not found : %s ’ % name)
OSError: File not found : /usr/local/lib/python35/dist-packages/trytond/modules/default_value/trytoncfg
Hi Ced,
I managed to restore the database, I created a custom image (Tryton 4.8) by transferring my custom modules (I used the COPY method in the dockerfile).
I have questions:
I copied the custom modules in the path: /usr/local/lib/python3.5/dist-packages/trytond/modules
it’s correct?
When I setup the database I get this error:
Traceback (most recent call last):
File “/ usr / local / bin / trytond-admin”, line 14, in
import trytond.admin as admin
File “/usr/local/lib/python3.5/dist-packages/trytond/admin.py”, line 12, in
from trytond.pool import Pool
File “/usr/local/lib/python3.5/dist-packages/trytond/pool.py”, line 6, in
from trytond.modules import load_modules, register_classes
File “/usr/local/lib/python3.5/dist-packages/trytond/modules/init.py”, line 10, in
import ConfigParser
ImportError: No module named ‘ConfigParser’