bigquery-emulator icon indicating copy to clipboard operation
bigquery-emulator copied to clipboard

Failed to run emulator in container with volumes and specified dataset for the second time

Open vladDotH opened this issue 9 months ago • 1 comments

What happened?

bq-emulator | failed to exec INSERT INTO datasets (id,projectID,tableIDs,modelIDs,routineIDs,metadata) VALUES (@id,@projectid,@tableids,@modelids,@routineids,@metadata): UNIQUE constraint failed: datasets.projectID, datasets.id bq-emulator exited with code 1

What did you expect to happen?

Normal container startup with saved volumes

How can we reproduce it (as minimally and precisely as possible)?

my docker-compose.yml:

services:
  bq-emulator:
    container_name: bq-emulator
    image: ghcr.io/goccy/bigquery-emulator:0.6.6
    command: --project=testproject --database=testdatabase --log-level=debug 
    ports:
      - 9050:9050
      - 9060:9060
    volumes:
      - ./work:/work
  1. run: docker compose up
  2. stop it docker compose down
  3. run again and further attempts will fail

Anything else we need to know?

Docker version:

Client: Docker Engine - Community Version: 28.0.4 API version: 1.48 Go version: go1.23.7 Git commit: b8034c0 Built: Tue Mar 25 15:07:16 2025 OS/Arch: linux/amd64 Context: default

Server: Docker Engine - Community Engine: Version: 28.0.4 API version: 1.48 (minimum version 1.24) Go version: go1.23.7 Git commit: 6430e49 Built: Tue Mar 25 15:07:16 2025 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.7.26 GitCommit: 753481ec61c7c8955a23d6ff7bc8e4daed455734 runc: Version: 1.2.5 GitCommit: v1.2.5-0-g59923ef docker-init: Version: 0.19.0 GitCommit: de40ad0

vladDotH avatar Apr 06 '25 16:04 vladDotH

I have the same issue too:

services:
  bigquery:
    image: ghcr.io/goccy/bigquery-emulator:latest
    command:
      - --project=local
      - --dataset=local
      - --database=/data/bq.db
    volumes:
      - bigquery-data:/data

volumes:
  bigquery-data:

@vladDotH did you solved it?


UPDATE: Its happening with the binary too, is not just in Docker

./bigquery-emulator-linux-amd64 --dataset local --project local --database this.db


UPDATE: The issue is related to pass dataset argument. Just using project and database args works fine. I think this must be handled in other way (like create if not exists, but not failing if exists).

./bigquery-emulator-linux-amd64 --dataset local --database this.db

Btw this is related to #237

raulsx avatar May 24 '25 01:05 raulsx