noamanelson@noamanelson-Virtual-Machine:~$ docker pull --help
Usage: docker pull [OPTIONS] NAME[:TAG|@DIGEST]
Download an image from a registry
Aliases:
docker image pull, docker pull
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
-q,--quiet Suppress verbose output
noamanelson@noamanelson-Virtual-Machine:~$
noamanelson@noamanelson-Virtual-Machine:~$ docker pull ubuntu:18.0418.04: Pulling from library/ubuntu
0c5227665c11: Pull complete
Digest: sha256:8aa9c2798215f99544d1ce7439ea9c3a6dfd82de607da1cec3a8a2fae005931b
Status: Downloaded newer image for ubuntu:18.04
docker.io/library/ubuntu:18.04
noamanelson@noamanelson-Virtual-Machine:~$
运行镜像,比如启动 bash 并且进行交互式操作:
docker run -it --rm ubuntu:18.04 bash
noamanelson@noamanelson-Virtual-Machine:~$ docker run -it --rm ubuntu:18.04 bash
root@36e7bfa463f2:/#
root@36e7bfa463f2:/#
root@36e7bfa463f2:/# lsbin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@36e7bfa463f2:/#
1.3 docker run说明
参数说明,可以使用docker run --help查看:
noamanelson@noamanelson-Virtual-Machine:~$ docker run --help
Usage: docker run [OPTIONS] IMAGE [COMMAND][ARG...]
Create and run a new container from an image
Aliases:
docker container run, docker run
Options:--add-host list Add a custom host-to-IP mapping (host:ip)-a,--attach list Attach to STDIN, STDOUT or STDERR
--blkio-weight uint16 Block IO (relative weight), between 10and1000,or0 to disable (default 0)--blkio-weight-device list Block IO weight (relative device weight)(default [])--cap-add list Add Linux capabilities
--cap-drop list Drop Linux capabilities
--cgroup-parent string Optional parent cgroup for the container
--cgroupns string Cgroup namespace to use (host|private)......
noamanelson@noamanelson-Virtual-Machine:~$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 18.04 3941d3b032a8 2 months ago 63.1MB
hello-world latest feb5d9fea6a5 19 months ago 13.3kB
noamanelson@noamanelson-Virtual-Machine:~$
参数说明:
参数
说明
REPOSITORY
仓库名
TAG
标签
IMAGE ID
镜像ID
CREATED
创建时间
SIZE
占用空间
2.2 镜像空间
这里的占用空间和Docker Hub 上看到的镜像大小不同;
下载的镜像是是展开后的各层所占空间的总和,Docker Hub 是压缩后的体积;
docker system df查看镜像、容器、数据卷所占用的空间:
noamanelson@noamanelson-Virtual-Machine:~$ docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 2163.16MB 63.15MB (99%)
Containers 10 0B 0B
Local Volumes 00 0B 0B
Build Cache 00 0B 0B
noamanelson@noamanelson-Virtual-Machine:~$