---
# System prepended metadata

title: docker(container)
tags: [Linux]

---

* volume test
```
docker volume create --name storage-c
docker pull busybox
docker run -v storage-c:/root -it busybox
cd /root
mkdir kkk
exit

cd /var/lib/docker/volumes/storage-c/_data
ls -alh
drwxr-xr-x 2 root root 6 Nov 12 10:25 kkk
```
* go in to container
```
docker exec -it <container-id> /bin/sh
or
docker exec -it <container-id> /bin/bash
```
```
docker-compose -f xxx.yaml exec gitlab /bin/bash
```
---
# 將container新增檔案並儲存
* docker commit id new-name (保存在container裡的檔案)
    * 这还仅仅是最简单的操作，如果是安装软件包、编译构建，那会有大量的无关内容被添加进来，将会导致镜像极为臃肿。
    * [說明](https://yeasy.gitbook.io/docker_practice/image/commit)
```
docker commit [选项] <容器ID或容器名> [<仓库名>[:<标签>]]
docker commit 88400ddfbf99 ubuntu:v2 對正在執行的container儲存新image, 並給予新名稱)
```

* 可使用Dockerfile打包新的image
Dockerfile:
```dockerfile=
FROM jupyter/minimal-notebook
RUN pip install pandas
```
```
docker build -t jtest . --no-cache
```
---
* docker information
```
docker inspect id
```

* volume mapping
in the yaml:
myapp:/home/node/app

* docker copy file to docker
```
docker cp foo.txt mycontainer:/home/vici/foo.txt
```

* docker-compose restart name (one docker)

* docker-compose up -d (down)

* docker inspect id

* docker save and load image
```
docker save name > name.tar
docker save -o name.tar name
docker export name | gzip > name.tgz

docker load name.tar

gunzip -c name.tgz | docker load

cat name.tar | docker import - [image name]
```

---
docker run -p 8080:8888 -v /Users/james/Documents/jupyter/work:/home/jovyan/work jupyter/minimal-notebook  

-v /Users/james/Documents/jupyter/work:/home/jovyan/work 


docker run -p 8080:8888 -v /Users/james/Documents/jupyter/work:/home/jovyan/work jtest

docker run -t -i --name=hinaExport local/jupyterv2:latest bin/bash

