How to execute commands while running this docker container?

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

  1. docker run -d -p 5432:5432 --name containername -e POSTGRES_PASSWORD=password -d postgres:12.1

  2. docker exec -it containername /bin/bash

  3. psql -h localhost -U postgres

  4. CREATE 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

Source: Docker Questions