Could not translate host name "postgres" to address using console in docker

Al ejecutar el comando ( docker run --rm -ti tryton/tryton trytond-console -d ) me aparece el siguiente error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/trytond/backend/postgresql/database.py", line 232, in __new__
    cursor_factory=LoggingCursor)
  File "/usr/lib/python3/dist-packages/psycopg2/pool.py", line 161, in __init__
    self, minconn, maxconn, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/psycopg2/pool.py", line 58, in __init__
    self._connect()
  File "/usr/lib/python3/dist-packages/psycopg2/pool.py", line 62, in _connect
    conn = psycopg2.connect(*self._args, **self._kwargs)
  File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not translate host name "postgres" to address: Name or service not known

Traceback (most recent call last):
  File "/usr/local/bin/trytond-console", line 22, in <module>
    console.run(options)
  File "/usr/local/lib/python3.7/dist-packages/trytond/console.py", line 45, in run
    with Transaction().start(db_name, 0, readonly=True):
  File "/usr/local/lib/python3.7/dist-packages/trytond/transaction.py", line 107, in start
    database = backend.Database(database_name).connect()
  File "/usr/local/lib/python3.7/dist-packages/trytond/backend/postgresql/database.py", line 232, in __new__
    cursor_factory=LoggingCursor)
  File "/usr/lib/python3/dist-packages/psycopg2/pool.py", line 161, in __init__
    self, minconn, maxconn, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/psycopg2/pool.py", line 58, in __init__
    self._connect()
  File "/usr/lib/python3/dist-packages/psycopg2/pool.py", line 62, in _connect
    conn = psycopg2.connect(*self._args, **self._kwargs)
  File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not translate host name "postgres" to address: Name or service not known

It seems you are running postgres in a separate container. So in order to be able to connect to it you should link it on the commandline. You can do that with:

$ docker run --link tryton-postgres:postgres

Your full command should be:

$ docker run --link tryton-postgres:postgres --rm -ti tryton/tryton trytond-console -d

Make sure tu update tryton-postgres with the name of the container running your postgres service. I just used the default docker configuration names that we use on our docker image, but you may need to alter it if you changed on the configuration.

Con los siguientes comandos logré ejecutar el trytond-console en docker:

Comando para escribir el código:
$ docker run --link tryton-postgres:postgres --env DB_PASSWORD=${POSTGRES_PASSWORD} --net tryton --rm -ti <image> trytond-console -d <database_name>

Comando para ejecutar el código desde un archivo:
$ docker run --link tryton-postgres:postgres --env DB_PASSWORD=${POSTGRES_PASSWORD} --net tryton --rm -i <image> trytond-console -d <database_name> < /path/file.py