0

There are a few questions about sending arguments to a command invoked with docker exec, but I'm struggling to translate the answers into something that works for my particular case, which is calling interactive SQL (isql) inside the container.

When I try:

docker exec -it virtuoso ../bin/isql $HOSTNAME dba dba ./rdf_inputs/insert_my_stff.isql

it shows that isql is invoked but somehow the parameters are all mixed up because it does not execute the insert_my_stuff ISQL script.

I tried putting the command all in quotes per the below but this does not help: passing arguments to docker exec from bash prompt and script

docker exec -it virtuoso sh -c "../bin/isql $HOSTNAME dba dba ./rdf_inputs/insert_my_stff.isql"

^ Also doesn't work.

If I manually exec into the container and execute:

../bin/isql $HOSTNAME dba dba ./rdf_inputs/insert_my_stff.isql

it works perfectly.

1
  • Do you need the docker exec debugging tool here, or can you run this command directly from the host system? You'd need the isql tool available locally, plus the file you're trying to load, and if you're trying to connect to the database running in the container ($HOSTNAME is localhost) it'd need published ports, but it's still probably a simpler setup on the whole. Commented May 28 at 10:28

1 Answer 1

1

How about doing such?

docker exec -i virtuoso sh -c '
  /opt/virtuoso/bin/isql-vt "$HOSTNAME" dba dba \
    /opt/virtuoso/rdf_inputs/insert_my_stff.isql'

-i only; no -t needed unless you want an interactive prompt after the script runs.

If the SQL file lives on your host and you don’t want to copy it into the container:

cat ./rdf_inputs/insert_my_stff.isql | docker exec -i virtuoso /opt/virtuoso/bin/isql-vt dba dba
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.