Here are some quick package.json scripts to create, remove, start, and stop a local docker postgres database.
{
"scripts": {
"db:create": "docker run --name DB_NAME -e POSTGRES_PASSWORD=postgres -p DB_EXTERNAL_PORT:5432 -d postgres",
"db:remove": "docker rm DB_NAME",
"db:start": "docker start DB_NAME",
"db:stop": "docker stop DB_NAME"
}
}
Used env vars:
DB_NAME
: Name for the docker container to create.
DB_EXTERNAL_PORT
: What local port the database should be accessible from. Use 5432 for default pg port.
Top comments (2)