## 引入本機資料 在container內使用外部檔案,設定 `--volume` 或 `-v` 並指定在container可以access的路徑名稱,例如: ``` ## my input file: /path/to/input/input.txt docker run -v /path/to/input:/data my_container:latest -input /data/input.txt ``` singularity 也有相似指令 `--bind` ``` singularity exec --bind /path/to/input:/data,/path/to/other:/index my_sing.sif -input /data/input.txt -output /index ``` ## 修改寫入權限 有時遇到 docker 輸出檔案的權限為 **root** ,若以後要修改刪除等操作會不方便,使用 `--user $(id -u):$(id -g)` 來將輸出的owner, group 權限給下指令的使用者,例如: ``` docker run -it -rm -v /path/to/input:/data --user $(id -u):$(id -g) my_container:latest -input /data/input.txt -output /data/output.txt ``` 若owner為使用者,之後還可通過linux `chgrp` 修改 group 權限 ## container執行完一併刪除 加上 `--rm` ## 用 Dockerfile 建立 docker 並使用 前陣子使用某docker遇到bug無法執行成功,因此稍微修改他的dockerfile -> push至dockerhub -> pull 回來使用 註1: 以下有匿名處理 docker name 請參考code就好XD 註2: 需要註冊 https://hub.docker.com/ 才能push 註3: [my references](https://ithelp.ithome.com.tw/articles/10192824) 首先登入dockerhub 建立新專案 回到linux建立docker ``` ## cd to dockerfile directory and build docker docker build -t local/origin_docker_fixed:latest . ## need user login docker login ## rename docker tag (origin TAG is <none>) ## the image name may be the same as the repository we created docker tag 53a8d0dbxxxx pxchen/origin_docker_fixed ## check docker image ls ## push to the existing repository docker push pxchen112/msisensor-pro-fixed ``` 回到 dockerhub,點進去看push的image 以及Dockerfile layer 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up