Can I run CockroachDB as a drop-in replacement for Postgres? #127648
Unanswered
fwoodruff-ab
asked this question in
Q&A
Replies: 1 comment
-
|
Yes, CockroachDB can work as a Postgres drop-in for basic use cases. Here's what to change: services:
db:
container_name: db
image: cockroachdb/cockroach:v24.1.2
command: start-single-node --insecure
restart: unless-stopped
ports:
- "26257:26257" # CockroachDB port
- "8080:8080" # Admin UI
environment:
- COCKROACH_DATABASE=postgres
- COCKROACH_USER=my_user
- COCKROACH_PASSWORD=my_password
volumes:
- my-cockroach-data:/cockroach/cockroach-data
- ./migrations/db_migration.sql:/docker-entrypoint-initdb.d/init.sql
volumes:
my-cockroach-data:Key differences:
Gotchas:
Test your migrations - some DDL might need adjustments for CockroachDB's distributed nature. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a vanilla docker-compose.yml file which runs some services against Postgres. Those services use github.com/jackc/pgx/v4 (among other Golang libraries) to talk to those databases, running migrations and then later making modifications and queries.
This link suggests that it might be possible to swap CockroachDB for Postgres without changing the application code.
If I swap
postgres:15forcockroachdb/cockroach:v24.1.2, what other changes should I make so that, as closely as possible, the application code still runs?Notably, I would like to connect to CockroachDB without TLS but with password login.
Beta Was this translation helpful? Give feedback.
All reactions