---
title: "เก็บข้อมูลด้วย Volume"
description: "ใช้ volume ให้ข้อมูลอยู่รอดแม้ลบ container ทิ้ง"
canonical_url: "https://iamthana.com/courses/docker-basics/volumes"
---

> Index of every page on this site: [llms.txt](https://iamthana.com/llms.txt)

ข้อมูลใน container หายไปพร้อม container เสมอ ใช้ volume เพื่อเก็บข้อมูลไว้นอก container

```bash
docker volume create data
docker run -d --name db -v data:/var/lib/postgresql/data -e POSTGRES_PASSWORD=example postgres:17
```

<warning>

`POSTGRES_PASSWORD` ในตัวอย่างนี้ใช้ทดสอบบนเครื่องตัวเองเท่านั้น

</warning>

## Sitemap

See the full [sitemap](https://iamthana.com/sitemap.md) for all pages.
