docker image ls [OPTIONS] [REPOSITORY[:TAG]] List images Aliases: ls, images, list Options: -a, --all Show all images (default hides intermediate images) --digests Show digests -f, --filter filter Filter output based on conditions provided --format string Pretty-print images using a Go template --no-trunc Don''t truncate output -q, --quiet Only show numeric IDs
從Aliases看出 java
docker images docker image ls docker image list
三條命令均可以查看docker image列表docker
docker image pull [OPTIONS] NAME[:TAG|@DIGEST] [flags] Options: -a, --all-tags Download all tagged images in the repository --disable-content-trust Skip image verification (default true) --platform string Set platform if server is multi-platform capable Params: NAME 鏡像名稱。鏡像能夠在Docker Store上查找其名稱。通常是 user/repo:tag的格式
鏡像能夠經過上述命令先獲取到本地。Docker的查詢在Docker Store進行。ubuntu
例如
搜索 niweigede 就會得到如下結果bash
能夠看出,這個鏡像的描述使用了ubuntu
,java-8
,ssh
以及tsinghua
的apt 源。網絡
獲取鏡像還能夠使用docker pull
命令ssh
docker image rm [OPTIONS] IMAGE [IMAGE...] Remove one or more images Aliases: rm, rmi, remove Options: -f, --force Force removal of the image --no-prune Do not delete untagged parents
刪除鏡像時,IMAGE參數能夠指定鏡像名稱或者鏡像ID。tcp
若是被刪除的鏡像A,在本地有基於A製做的鏡像B,則直接刪除A會報'conflict: unable to delete 5a662682895c (cannot be forced) - image has dependent child images'錯誤。此時須要先解除關聯,也就是先刪除B才能繼續刪除Aide
docker run [OPTIONS] IMAGE [COMMAND] [ARG...] Run a command in a new container
run
命令下的OPTIONS
比較多,這裏不徹底羅列,須要的請自行查詢。ui
docker run -i -t niweigede/ujava:1.1
上述命令表示基於鏡像niweigede/ujava:1.1
打開一個新的container。其中-i
表示保持一個標準輸入STDIN
,-t
表示分配一個虛擬控制檯TTY
用於與container進行交互spa
docker run -it -p 8070:8080 niweigede/ujava:1.1
使用命令-p
端口映射,詳細的使用方式以下
format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort Both hostPort and containerPort can be specified as a range of ports. When specifying ranges for both, the number of container ports in the range must match the number of host ports in the range. (e.g., `-p 1234-1236:1234-1236/tcp`)
docker run -it --name CUSTOMER_NAME niweigede/ujava:1.1
使用命令--name
給即將運行的container分配一個自定的名稱"CUSTOMER_NAME"
docker run -it -v /home/host:/home/container niweigede/ujava:1.1
使用命令-v
進行數據卷掛載,詳細的使用方式以下
Create a bind mount with: [host-dir:]container-dir[:rw|ro]. If 'host-dir' is missing, then docker creates a new volume. If neither 'rw' or 'ro' is specified then the volume is mounted in read-write mode.