Setup a PostgreSQL Docker container in under 20 seconds

Supposing you’ve already installed docker by following these instructions, just go ahead and type:

sudo docker run --name some-postgres \
    -p 5432:5432 \
    -e POSTGRES_PASSWORD=dev \
    -d \
    postgres

You can now easily create a database using:

sudo docker exec -it "some-postgres" \
    psql -U postgres -c "CREATE DATABASE your_db_name;"

Bam! You’re done.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.