无法通过bash脚本创buildpostgres扩展

在Docker容器中启动了一个postgres数据库,然后想用以下脚本安装扩展:

su postgres sh -c "psql -U postgres <<EOSQL CREATE EXTENSION hstore; CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology; CREATE EXTENSION fuzzystrmatch; EOSQL" trap "echo \"Sending SIGTERM to postgres\"; killall -s SIGTERM postgres" SIGTERM su postgres sh -c "$POSTGRES -D $DATADIR -c config_file=$CONF" & wait $! 

但它什么都不做,在扩展列表中只安装了一个默认的plpgsql。

但如果我input容器

 docker exec -it osm-database bash 

并按顺序在cli中运行以下命令

 su postgres psql -U postgres create extension hstore; 

那么我可以从pgAdmin hstore中看到安装成功