記錄最近跑 docker / singularity 的指令
引入本機資料
在container內使用外部檔案,設定 --volume
或 -v
並指定在container可以access的路徑名稱,例如:
|
|
singularity 也有相似指令 --bind
|
|
修改寫入權限
有時遇到 docker 輸出檔案的權限為 root ,若以後要修改刪除等操作會不方便,使用 --user $(id -u):$(id -g)
來將輸出的owner, group 權限給下指令的使用者,例如:
|
|
若owner為使用者,之後還可通過linux chgrp
修改 group 權限
其他指令
加上 --rm
讓container執行完一併刪除
加上 --it
進入互動模式,但有可能出現 the input device is not a TTY
錯誤
用 Dockerfile 建立 docker 並使用
前陣子使用某docker遇到bug無法執行成功,因此稍微修改他的dockerfile -> push至dockerhub -> pull 回來使用 註1: 以下有匿名處理 docker name 請參考code就好XD 註2: 需要註冊 https://hub.docker.com/ 才能push 註3: my references
首先登入dockerhub 建立新專案
回到linux建立docker
|
|
回到 dockerhub,點進去看push的image 以及Dockerfile layer

常用的 image base
基礎映像 | 標籤 | 特點 |
---|---|---|
Alpine Linux | alpine:latest |
輕量、安全、適合容器化應用,小映像大小 |
Ubuntu | ubuntu:latest |
廣泛使用的 Linux 發行版,功能豐富 |
CentOS | centos:latest |
穩定、適用於企業級應用,基於 RHEL |
Debian | debian:latest |
穩定,有廣泛的套件庫 |
Scratch | scratch |
最小化基礎映像,不包含操作系統 |
Golang | golang:latest |
包含 Go 程序語言和開發工具的基礎映像 |
Node.js | node:latest |
包含 Node.js 環境的基礎映像 |
將建立好的 docker 存成 tar 檔並加載到其他環境
|
|