Docker使用心得
来源:互联网 发布:流量互换源码 编辑:程序博客网 时间:2024/06/11 04:28
近来希望dockerize puppet+foreman,puppet+foreman docker化过程有点坎坷,将另写新文记录其中的过程,现将使用docker的命令记录下来。
- docker pull
- docker images
- docker run
- docker commit
- docker ps
- docker rm
- docker rmi
docker pull
docker images
docker run
docker commit
docker ps
docker images
docker pull
这个命令用于拉取(下载)镜像,默认从Docker Hub拉取(下载)镜像至本地的graph中,需要注意的是Docker Hub并没有在国内部署服务器或者使用国内的CDN服务,下载的速率慢,因此出现了国内的registry mirror,例如DaoCloud。
graph在宿主机本地的存储路径为/var/lib/docker/graph,具体存储的信息有:该容器镜像的元数据,容器镜像的大小信息,以及该容器镜像所代表的具体rootfs。
Usage: docker pull [OPTIONS] NAME[:TAG|@DIGEST]
docker images
用于查看本地保存的镜像(image)
Usage: docker images [OPTIONS] [REPOSITORY[:TAG]]
Options:
-a, –all Show all images (default hides intermediate images)
–digests Show digests
-f, –filter value Filter output based on conditions provided (default [])
docker run
docker run是利用已有的镜像(image)创建一个容器(container),docker会为该容器(container)启动一个进程并分配独立的文件系统及网络资源,docker run命令在实际中使用频率比较高,因此选项较多,以下是常用的选项。
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG…]
Options:
-t, –tty Allocate a pseudo-TTY
-i, –interactive Keep STDIN open even if not attached
-h, –hostname string Container host name
-p, –publish value Publish a container’s port(s) to the host (default [])
-P, –publish-all Publish all exposed ports to random ports
-v, –volume value Bind mount a volume (default []). The format is[host-src:]container-dest[:<options>]
.The comma-delimitedoptions
are [rw|ro],[z|Z], [[r]shared|[r]slave|[r]private], and [nocopy]. The ‘host-src’ is an absolute pathor a name value.
–privileged Give extended privileges to this container
-d, –detach Run container in background and print container ID
–restart string Restart policy to apply when a container exits (default “no”) Possible values are : no, on-failure[:max-retry], always, unless-stopped
docker commit
当对容器(container)做了修改以后,可以利用docker commit将当前容器的状态保存为一个新的镜像(image)
Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
Options:
-a, –author string Author (e.g., “John Hannibal Smith hannibal@a-team.com”)
-c, –change value Apply Dockerfile instruction to the created image (default [])
-m, –message string Commit message
-p, –pause Pause container during commit (default true)>a
docker ps
docker ps 用于列出容器的id、状态等等信息,不带参数默认只显示出当前正在运行的容器。
Usage: docker ps [OPTIONS]
Options:
-a, –all Show all containers (default shows just running)
-f, –filter value Filter output based on conditions provided (default [])
- exited= an exit code of
- label= or label==
- status=(created|restarting|running|paused|exited)
- name= a container’s name
- id= a container’s ID
docker rm
用于删除容器(container),不带任何参数的情况下,只能删除处于未运行状态的容器。
Usage: docker rm [OPTIONS] CONTAINER [CONTAINER…]
Options:
-f, –force Force the removal of a running container (uses SIGKILL)
-l, –link Remove the specified link
-v, –volumes Remove the volumes associated with the container
docker rmi
删除镜像(image),不带任何参数的情况下,只能删除未被使用的镜像。
Usage: docker rmi [OPTIONS] IMAGE [IMAGE…]
Options:
-f, –force Force removal of the image
–no-prune Do not delete untagged parents>a
- Docker使用心得
- Docker使用心得
- Docker使用心得
- [心得] docker目录迁移心法
- 【Docker】Docker使用原则
- 【Docker】 windows10 docker 使用
- Docker使用
- docker 使用
- docker 使用
- docker使用
- 使用Docker
- docker使用
- docker使用
- docker使用
- Docker使用
- docker使用
- docker使用
- docker使用
- python os模块常用命令
- IOS中使用UITableViewCell的按钮事件
- 【BZOJ 3157, 3516, 4126】 国王奇遇记 - 极致的组合数学
- jq框架封装学习笔记1-框架介绍与选择器框架
- rmmod: chdir(/lib/modules): No such file or directory
- Docker使用心得
- iWorkTime项目开发简介
- 《The two second acdvantage》读书笔记
- [嵌入式]Cortex-A8处理器编程(上)
- jq框架封装学习笔记2-选择模块
- oracle学习之:解锁用户
- 单例模式——懒汉式和饿汉式
- [github高级控件]带你走近->自定义标签云
- JQuery中的一些重要方法