Customize the Tryton Container

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.