I want to pull docker postgres image and create a database mydb in it. I am able to do it step by step like this
docker run -d -p 5432:5432 --name containername -e POSTGRES_PASSWORD=password -d postgres:12.1docker exec -it containername /bin/bashpsql -h localhost -U postgresCREATE database mydb;
I wanted to add these steps in a readme documentation. Is it possible to do everything in a single command when running the container itself? Tried something like below but couldn't succeed
docker run -d -p 5432:5432 --name terminals -e POSTGRES_PASSWORD=password -d postgres:12.1 psql -h localhost -U postgres; create database terminals
You can mount a init script into container:
your-init.sql: