I am trying to execute a bash command in docker but I'm having trouble figuring out how to escape the single quotes around the table name user_mappings
in my command. I've tried backslashes, double single quotes, and double quoted single quotes.
I know I could get around it if I didn't wrap the command in bash -c
, but I need that so I can redirect the output to a file in the container.
# docker container exec 1b8 bash -c 'psql -c "SELECT * FROM information_schema.tables where table_name='user_mappings'" > /tmp/output'
ERROR: column "user_mappings" does not exist
LINE 1: ...* FROM information_schema.tables where table_name=user_mappi...