Dev Environment with Docker
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 containerredis-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 defaultpostgresuser.-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:
localhostPort:
5432User:
postgresPassword:
mysecretpassword

