localhost == 127.0.0.1 == 本機ipnode
ifconfig 或者 ip addr 查看本地宿主機的ip地址docker
$ docker help
Usage: docker [OPTIONS] COMMAND [arg...]
docker [ --help | -v | --version ]
A self-sufficient runtime for containers.
Options:
--config=~/.docker Location of client config files
-D, --debug Enable debug mode
-H, --host=[] Daemon socket(s) to connect to
-h, --help Print usage
-l, --log-level=info Set the logging level
--tls Use TLS; implied by --tlsverify
--tlscacert=~/.docker/ca.pem Trust certs signed only by this CA
--tlscert=~/.docker/cert.pem Path to TLS certificate file
--tlskey=~/.docker/key.pem Path to TLS key file
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Commands:
attach Attach to a running container 附着到正在運行的容器
build Build an image from a Dockerfile 從一個Dockerfile構建鏡像 -t,爲新鏡像設置倉庫和名稱,標籤 -f,指定一個區別於標準的Dockerfile的構建源的位置,文件能夠不命名爲Dockerfile 推薦使用 Dockerfile Dockerfile指令按順序從上到下執行 Dockerfile每條指令都要是大寫字母后面跟一個參數 Dockerfile每條指令都建立一個新的鏡像層並對鏡像進行提交
commit Create a new image from a container's changes 提交修改過的容器構建一個新的鏡像 -m,指定提交信息 -a,做者信息 提交的是容器鏡像與當前狀態有差別的部分,很是輕量 不推薦使用commit構建鏡像
cp Copy files/folders between a container and the local filesystem
create Create a new container 建立一個容器單是並不運行它
diff Inspect changes on a container's filesystem
events Get real time events from the server
exec Run a command in a running container 在正在運行的容器中執行命令 -d,在內部執行後臺命令
export Export a container's filesystem as a tar archive
history Show the history of an image 顯示鏡像使如何被構建出來的歷史
images List images 列出docker鏡像 image xxx,只查看指定鏡像名xxx的鏡像 全部鏡像都在/var/lib/docker/aufs下或者/var/lib/docker/devicemapper下
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on a container, image or task 獲取容器,鏡像,任務的底層詳細信息 --format,指定查看結果
kill Kill one or more running containers 快速中止正在運行的容器
load Load an image from a tar archive or STDIN
login Log in to a Docker registry. 登錄到Docker Cloud,須要提早註冊帳號和密碼 我的認證信息保存在¥HOME/.docker/config.json中
logout Log out from a Docker registry.
logs Fetch the logs of a container 獲取容器日誌 -f,跟蹤實時日誌 -t,給日誌加時間戳 logs --tail 10 -ft,跟蹤並獲取日誌最後10行加時間戳的內容
network Manage Docker networks
node Manage Docker Swarm nodes
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container 查看容器的端口映射或指定端口的映射狀況
ps List containers 容器列表 -a,列出全部容器 -l,列出最後使用的容器 ps -n x,顯示最後運行的x個容器 全部容器都在/var/lib/docker/containers下
pull Pull an image or a repository from a registry 從庫中拉取鏡像
push Push an image or a repository to a registry
rename Rename a container
restart Restart a container 從新啓動一個容器
rm Remove one or more containers 刪除容器 -f,強制刪除正在運行的容器 rm ‘docker ps -a -q’,刪除全部容器
rmi Remove one or more images
run Run a command in a new container 建立並啓動一個新的容器而後運行指定命令 -i,保證容器中STDIN開啓 -t,告訴容器分配一個僞tty終端 --name,爲容器指定名稱 -d,將容器放到後臺運行 -c,指定容器中運行的命令 -g,指定容器中運行的命令 -p,Docker運行時開放哪些端口給外部宿主機 宿主機端口能夠是隨機端口,或指定特定端口,或特定主機的隨機端口,或特定主機的特定端口,冒號分割,以前是宿主機以後是Docker容器端口,也能夠指定UDP端口 -P,對外公開在Dockerfile中經過EXPOSE指令公開的全部端口,對應的宿主機端口隨機選擇 --restart=always,自動重啓該容器 --restart=on-failure,退出代碼非零自動重啓 未指定具體鏡像標籤,則直接下載latest標籤鏡像
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images 查找全部Docker Hub上的公共可用鏡像
service Manage Docker services
start Start one or more stopped containers 啓動一個已經中止的容器
stats Display a live stream of container(s) resource usage statistics 顯示容器(s)的資源使用實時統計流
stop Stop one or more running containers 中止正在運行的容器
swarm Manage Docker Swarm
tag Tag an image into a repository
top Display the running processes of a container 查看容器中的進程
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
volume Manage Docker volumes
wait Block until a container stops, then print its exit code
json