A minimal repository for exxperimenting with POSTGRESQL using Docker.
To start the container:
./scripts/create-container.sh
To begin interacting with the container:
./scripts/attach-container.sh
docker run --name example-db --mount type=bind,source="$(pwd)",dst="/code" -e POSTGRES_PASSWORD=password -d postgres
docker run
- start a container based on an image--name example-db
- give the container a name for convenience--mount type=bind,source="$(pwd)",dst="/code"
- connect the current working director (host machine) to the/code
folder on the container-e POSTGRES_PASSWORD=password
- give the container an environment variable-d
- run the container behind the scenespostgres
- the image to base it on
docker exec -it example-db psql -U postgres
docker exec
- execute a command in a running container-it
- using an interactive terminalexample-db
- the name of the containerpsql
- the command to run (psql
lets you talk to POSTGRES databases)-U postgres
- an argument to thepsql
command: the username