---
description: docker
---

# 20190327

查詢docker資訊

```
# docker inspect [id]
```

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaxhsmC4lyMeyB5RuyL%2F-Laxj60lFUkddCcl5aCE%2Fimage.png?alt=media\&token=612f4788-d858-482c-b9a4-614bad36cc78)

執行docker httpd

```
# docker run -d -p 8080:80 httpd
```

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaxhsmC4lyMeyB5RuyL%2F-LaxjmbbQZn9h95VWUKp%2Fimage.png?alt=media\&token=2a2d4963-ec7c-423a-9f94-c24cea9a0f99)

成功的網頁會像這樣

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaxhsmC4lyMeyB5RuyL%2F-LaxkDllbA7Fb2w7lMF0%2Fimage.png?alt=media\&token=8f311f20-ddeb-4ea9-99ea-5f190f799957)

接下來創建一個資料夾叫mydata

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaxhsmC4lyMeyB5RuyL%2F-Laxkvgt7nT8kM7D_K92%2Fimage.png?alt=media\&token=ae8f25cf-9bc3-48db-9dc6-38ae261ecc1f)

執行

```
# docker run -it --rm -v /mydata:/data centos /bin/bash
```

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaxhsmC4lyMeyB5RuyL%2F-LaxlMUlpYoCWShI0FcT%2Fimage.png?alt=media\&token=22860b5b-37f1-43a9-8167-0a8f3d787c38)

成功後root會變成這樣

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaxhsmC4lyMeyB5RuyL%2F-LaxlcNoNJ6OgDwZfyG5%2Fimage.png?alt=media\&token=8655aaa3-d78c-4637-a0f8-ab4fd60167a1)

切換到data資料夾底下

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaxhsmC4lyMeyB5RuyL%2F-Laxloe9iSkC5PB95NyQ%2Fimage.png?alt=media\&token=d041ac4e-3f63-48b0-86d7-609a39cbe043)

在資料夾底下創建任意文檔

```
# echo "hi" > a.txt
```

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaxhsmC4lyMeyB5RuyL%2F-LaxmK3mcv7MslicWuI7%2Fimage.png?alt=media\&token=4fa976f9-6062-411d-b0a7-241f9e8cd9f7)

開啟新的終端機切換到mydata資料夾下

確認資料夾下有沒有"a.txt"檔

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaxnJl8eZRxbq-il5uN%2F-LaxnmgjfwOGxOBwd3j3%2Fimage.png?alt=media\&token=7b7d08e3-4123-4008-8a29-9d6f2b54f1d0)

你也可以在mydata資料夾下創建文件

確認data資料夾是否跟mydata同步

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaxnJl8eZRxbq-il5uN%2F-Laxo7k5GynriImKm-rX%2Fimage.png?alt=media\&token=d92ec784-81b3-4c85-a90c-dd589fd19ef1)



![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaxnJl8eZRxbq-il5uN%2F-LaxoPrgtoZPzRCrOKEy%2Fimage.png?alt=media\&token=c83655aa-6517-4464-aa50-2780da24de2d)

