# Dev Environment with Docker

<a href="#"> Redis</a>

<a href="#PSQL"> PostgreSQL</a>
<div id="Redis"  />


### 1\. Redis

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

### 🔹 Basic Command

```bash
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:

```bash
docker exec -it redis-server redis-cli
```
<div id="PSQL"  />

---

### 2\. PostgreSQL 

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

---

### 🔹 Basic Command

```bash
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:

```bash
docker exec -it postgres-db psql -U postgres
```

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

* **Host:** [`localhost`](http://localhost)
    
* **Port:** `5432`
    
* **User:** `postgres`
    
* **Password:** `mysecretpassword`
    

---
