Type of build:
Technically, this is a Docker-in-Docker type of scenario. Think of it like a host container with a database container inside of it.
The command “docker run --name pgdock -d -p 5432:5432 postgres:12.1” was executed, exposing ports.
Objective(s):
Command/commands to:
Connect to postgres container from host (a container defined by Gitlab CI)
Display all databases to ensure they were built properly (display them inside host/host container to confirm)
All without having to have any manual input aside from the command itself
Attempts:
I tried docker exec -it pgdock
etc. etc. but had a TTY issue with the -t flag (because it’s not very interactive in a pipeline)
I ran this command to get access to the container from host:
Docker exec pgdock bash -c "psql -U postgres; /l
result: /l wasn’t found in bash. I figured the first command in the list would log into psql and then I could execute /l to display all databases.
BUT
Docker exec pgdock bash -c "psql -U postgres"
does work and most other forms of this command (using -i flag etc.)
Thanks for reading everyone, I hope this is digestible–as this is my first post!