Skip to main content

Command Palette

Search for a command to run...

Dev Environment with Docker

Updated
2 min read

Redis

PostgreSQL

1. Redis

To start Redis using Docker, you can run a container from the official Redis image. Here’s a quick guide:

🔹 Basic Command

docker run --name redis-server -p 6379:6379 -d redis

🔍 Explanation:

  • --name redis-server: Names the container redis-server.

  • -p 6379:6379: Maps port 6379 from the container to your host (default Redis port).

  • -d: Runs the container in detached mode (in the background).

  • redis: Uses the official Redis image from Docker Hub.


🧪 To Test Redis Is Running:

You can connect to it using another container:

docker exec -it redis-server redis-cli

2. PostgreSQL

To start PostgreSQL using Docker, here's a simple and effective way to get it running:


🔹 Basic Command

docker run --name postgres-db -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres

🔍 Explanation:

  • --name postgres-db: Names the container.

  • -e POSTGRES_PASSWORD=...: Sets the password for the default postgres user.

  • -p 5432:5432: Maps PostgreSQL's default port.

  • -d: Detached mode.

  • postgres: Uses the official PostgreSQL image.


🧪 Connect to PostgreSQL

You can connect using:

docker exec -it postgres-db psql -U postgres

Or with any GUI tool (like pgAdmin, DBeaver, TablePlus), using:

  • Host: localhost

  • Port: 5432

  • User: postgres

  • Password: mysecretpassword


More from this blog

B

Blog Nishaanth

17 posts