Skip to content

docker-entrypoint-initdb.d scripts don't run unless COCKROACH_USER is set #110997

Open
@brianvans

Description

@brianvans

Describe the problem

We rely on the /docker-entrypoint-initdb.d directory to run a script to initialize some databases, and we've run into some inconsistent behavior with start-single-node wherein the scripts under that directory don't get run if COCKROACH_USER isn't set. It seems like it's because the entrypoint is opening an interactive cockroach sql session which blocks execution of the scripts under /docker-entrypoint-initdb.d.

I'm wondering if opening an interactive cockroach sql session is intended behavior, or an unintentional result of calling run_sql_query without any query arguments here.

To Reproduce

echo 'CREATE DATABASE IF NOT EXISTS "hello_world";' > init-db.sql
docker run \
  -ti \
  --rm \
  -v $PWD/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql \
  -p 26257:26257 \
  cockroachdb/cockroach:v23.1.10 \
  start-single-node --insecure

Expected behavior

A single node instance is started up and the "hello_world" database exists.

Jira issue: CRDB-31707

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.E-easyEasy issue to tackle, requires little or no CockroachDB experienceO-communityOriginated from the communityT-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)good first issue

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions