Testcontainers execInContainer Not Working with Cockroachdb

I'm using Testcontainers to start a CockroachDB instance with docker. I need to enable support for temporary tables by setting the property sql.defaults.experimental_temporary_tables.enabled to true.

When the machine is running, I can do it with:

docker exec -it CockroachDBHibernate ./cockroach sql --insecure -e "SET CLUSTER SETTING sql.defaults.experimental_temporary_tables.enabled = 'true';"

But when I try to run the same command with Testcontainers:

container.execInContainer(
                    "./cockroach sql --insecure -e \"SET CLUSTER SETTING sql.defaults.experimental_temporary_tables.enabled = 'true';\"" );

I have the following error:

OCI runtime exec failed: exec failed: container_linux.go:370: starting container process caused: exec: "./cockroach sql --insecure -e \"SET CLUSTER SETTING sql.defaults.experimental_temporary_tables.enabled = 'true';\"": stat ./cockroach sql --insecure -e "SET CLUSTER SETTING sql.defaults.experimental_temporary_tables.enabled = 'true';": no such file or directory: unknown

Note that the error is visible via Container.ExecResult#getStdout(). Exit code is 126

I'm using Testcontainers 1.15.2 and CockroachDB v20.2.5

Thanks

1 Answer

 container.execInContainer( "sh", "-c", "./cockroach sql --insecure -e \"SET CLUSTER SETTING sql.defaults.experimental_temporary_tables.enabled = 'true';\"" );

Your Answer

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

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest