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.