https://github.com/vrudas/docker-playground
Docker playground with examples
https://github.com/vrudas/docker-playground
Last synced: 5 months ago
JSON representation
Docker playground with examples
- Host: GitHub
- URL: https://github.com/vrudas/docker-playground
- Owner: vrudas
- License: apache-2.0
- Created: 2024-03-16T14:41:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-11T09:41:27.000Z (over 1 year ago)
- Last Synced: 2025-04-26T07:08:06.021Z (6 months ago)
- Language: Kotlin
- Size: 1.57 MB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Docker Playground
## Idea
- Idea comes independently but implementation was inspired from https://github.com/kedziorski/test-db-pg-dvdrental
repository## DVD Rental Database
PostgreSQL DVD Rental database very useful to test purposes and playing with queries.
The main task was to create Docker image containing ready to use database example with sample data.
I used sample database from PostgreSQL Tutorial and created Dockerfile to run postgres and restore db from backup.## Useful links
- [Docker documentation](https://docs.docker.com/)
- [Postgres image](https://hub.docker.com/_/postgres/)
- [PostgreSQL Tutorial](http://www.postgresqltutorial.com/postgresql-sample-database/)## PostgreSQL Tutorial ER Diagram
## Building docker image
First of all we have to build docker image. We can do it by execute:
```docker
docker build -t pg_dvdrental .
```
Docker will download all needed dependencies and build image with name "pg_dvdrental". We can check it by execute:
```docker
docker images
```## Running docker container
To run created image we have to execute "docker run" like this:
```docker
docker run -p 5433:5432 --name dvdrental -d pg_dvdrental
```
Docker will run container with name "dvdrental", based on image "pg_dvdrental" and it will expose containers port 5432 on localhost port 5433.## Connect to database
Now we can connect to our database. First we need credentials:
```
Database name: dvdrental
Database user: postgres
Database password: postgres
```So lets check it using "docker" and "psql":
```docker
docker run -it --rm --link dvdrental:postgres postgres psql -h postgres -U dvdrental -d dvdrental
```
After put password ("dvdrental" to remind) we are connected to database and we can do queries. Let's check actors:
```postgresql
SELECT * FROM actor WHERE first_name ilike 'Kevin';
```