---
description: docker
---

# 20190320

{% embed url="http://www.runoob.com/docker/docker-commit-command.html" %}

如果想在容器內看到ip位置

```
# yum install net-tools
```

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaOwiaHzecR1RlXeJll%2F-LaOy0z7Am7ZN3R4wkPr%2Fimage.png?alt=media\&token=dcf9bbd1-02b9-4b91-b242-6b6c4d81232c)

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaOwiaHzecR1RlXeJll%2F-LaOyEHqaDDu4YHWdJYj%2Fimage.png?alt=media\&token=ee4793e7-0429-4cf0-9214-6eebb8ee6bd5)

可以在開另一台容器架好ip然後ping看看

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaOwiaHzecR1RlXeJll%2F-LaOykpRSjhSrer7x4Pc%2Fimage.png?alt=media\&token=0e7c7e81-e6eb-4554-a94a-d9cfba133795)

可以看到2個容器可以互相ping到

如果想要再進去之前的容器內，可以執行:

```
docker start [ID] or [名稱]
docker attach [ID] or [名稱]
```

```
# docker start 2f7
# docker attach 2f7
# docker stop 2f7
```

如果想要在同一個容器內執行多個終端機時

```
# docker exec -it 2f7 /bin/bash
```

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaOwiaHzecR1RlXeJll%2F-LaP2j_Qd8ObrZPfbkoq%2Fimage.png?alt=media\&token=a71cff02-ec32-467e-bdf6-05db7b98bc96)

複製容器

```
#docker commit [ID] [新的容器名稱]:0.1
```

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaOwiaHzecR1RlXeJll%2F-LaP38sAYsduAsov5LVI%2Fimage.png?alt=media\&token=57bd5c26-8674-4963-a648-b4095bde7067)

```
# docker run -it --name=[新名稱] test:0.1 /bin/bash
```

![複製過的容器會保有原來容器內的東西](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaOwiaHzecR1RlXeJll%2F-LaP3Y2ahEmd-LlkMIDI%2Fimage.png?alt=media\&token=dd22a60c-4c8c-4d73-9125-5ff64d9593ed)

將容器上傳

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaOwiaHzecR1RlXeJll%2F-LaP4KSQBvgwweNjz1hE%2Fimage.png?alt=media\&token=c78c52d6-2e74-4c9a-a712-c535e7c850c4)

![成功上傳docker hub](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaOwiaHzecR1RlXeJll%2F-LaP4eqCk9NYw1j5-V71%2Fimage.png?alt=media\&token=1b271ffc-2871-419d-816f-be1cf9ea21d0)

刪除images檔，從docker hub上下載回來。

```
# docker rmi [docker hub 帳號]/test:0.1
```

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LaP5dfv5PRTjLEHy1v_%2F-LaP5kcr_AetoGW7RcFH%2Fimage.png?alt=media\&token=cfbffa31-5d85-46af-8034-3e1965c45e0c)

成功將檔案抓回來了。
