I am running a postgresql in docker container and trying to insert some sample data into this database.
prepare_source_data.sql exists in the host environment.
here I tried
docker exec -it postgres bash psql "postgres://postgres:postgres@localhost/test" -f ./prepare_source_data.sql
but got some errors
/usr/bin/psql: line 19: use: command not found
/usr/bin/psql: line 20: use: command not found
/usr/bin/psql: line 21: use: command not found
/usr/bin/psql: line 22: use: command not found
/usr/bin/psql: psql: line 24: syntax error near unexpected token `$version,'
/usr/bin/psql: psql: line 24: `my ($version, $cluster);'
However executing the commands work well
docker exec -it postgres bash and then psql -U postgres
any idea how would I insert the data into the container in the host environment
syntax error near unexpected token ``$version,'is pretty clear.psqlis not accepting$version, which is understandable as there is nothing here psql that says it does. The closest you get is$1, etc withbind. You will need to show what is inprepare_source_data.sqland also give some explanation of what you expect the script to do.docker execdebugging tool at all for this. Use thepsqlclient directly from your host system, targeting the firstdocker run -por Composeports:number you used when you started the database container. This also saves you the trouble of copying the file into the container.