-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c07fcd7
commit 2a265f5
Showing
1 changed file
with
7 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
# Practice - using volumes | ||
|
||
Run a container "mypsql" using **postgres:12** with options to: | ||
- run the container in detached mode | ||
- pass an environment variable `POSTGRES_PASSWORD=secretpass` | ||
- create a named volume with `-v <name>:/var/lib/postgresql/data` | ||
Run a container **mypsql** using **postgres:12** with options to: | ||
- run in detached mode | ||
- pass the appropriate environment variable (find it on https://hub.docker.com/) | ||
- use a named volume | ||
|
||
Run a shell in the container and use psql to add a table and a record: | ||
Run bash in the container and use psql to add a table and a record: | ||
- $ `psql -U postgres` | ||
- $ `create table public.films (id int PRIMARY KEY, name varchar(255));` | ||
- $ `insert into films(id, name) values(1, 'Some movie');` | ||
|
||
Exit the container and delete it. Run a new container with the same options. Use ***the same*** volume name to re-use the existing volume. | ||
Exit the container and delete it. Run a new container with the same options (use ***the same*** volume name). | ||
|
||
Run a shell inside the container and see if your data is still there: | ||
Run bash inside the new container and see if your data has survived: | ||
- $ `psql –U postgres` | ||
- $ `select * from public.films;` |