CentOS安装docker及docker命令(更新中)

docker hub

安装和启动

yum install docker
service docker start      #或 systemctl  start docker.service
chkconfig docker on       #或 systemctl  enable docker.service

docker [OPTIONS]

  • --config=~/.docker 用户配置文件
  • -D, --debug debug模式
  • -H, --host=[] 以守护进程的方式连接
  • -h, --help 帮助
  • -l, --log-level=info 设置日志类别
  • --tls 使用传输层安全协议
  • --tlscacert=~/.docker/ca.pem CA地址
  • --tlscert=~/.docker/cert.pem 证书地址
  • --tlskey=~/.docker/key.pem 密钥地址
  • --tlsverify 使用传输层安全协议
  • -v, --version 打印版本号并退出

docker [COMMANDS]

attach

绑定窗口到某个已经在运行的容器:docker attach [OPTIONS] CONTAINER

  • --detach-keys 重置key
  • --no-stdin 非标准输入
  • sig-proxy=true 代理所有接收信号的进程

build

创建镜像文件

  • --build-arg=[] 变量
  • --cpu-shares CPU 共享 (相对权重)
  • --cgroup-parent 设置容器组
  • --cpu-period Limit the CPU CFS (Completely Fair Scheduler完全公平调度) period
  • --cpu-quota Limit the CPU CFS (Completely Fair Scheduler完全公平调度) quota
  • --cpuset-cpus CPUs in which to allow execution (0-3, 0,1),允许执行的cpu数
  • --cpuset-mems MEMs in which to allow execution (0-3, 0,1),允许执行的内存数
  • --disable-content-trust=true Skip image verification,跳过镜像验证
  • -f, --file Name of the Dockerfile (Default is 'PATH/Dockerfile'),dockerfile文件地址
  • --force-rm Always remove intermediate containers,强制删除相关容器
  • --help Print usage,帮助
  • --isolation Container isolation level,容器孤立等级
  • -m, --memory Memory limit,内存限制
  • --memory-swap Swap limit equal to memory plus swap: '-1' to enable unlimited swap,内存缓冲区限制
  • --no-cache Do not use cache when building the image,创建镜像时不使用缓存
  • --pull Always attempt to pull a newer version of the image,总是拉取最新版的镜像
  • -q, --quiet Suppress the build output and print image ID on success,隐藏输出,并打印镜像ID
  • --rm=true Remove intermediate containers after a successful build,成功创建时移除相关容器
  • --shm-size Size of /dev/shm, default value is 64MB,
  • -t, --tag=[] Name and optionally a tag in the 'name:tag' format
  • --ulimit=[] Ulimit options
  • -v, --volume=[] Set build-time bind mounts

commit

记录镜像:docker commit [ID] [repository]

  • -a 作者
  • -c,--change=[]
  • -m commit message
  • -p,--pause=true commit过程中暂停

cp

create

diff

events

exec

export

history

images命令

查看镜像:docker images 镜像名

  • -a 显示全部
  • --digests 摘要显示
  • -q 仅显示ID

import

info

inspect

docker inspect [OPTIONS] CONTAINER|IMAGE [CONTAINER|IMAGE...]

kill

load

login

登陆镜像

  • -e,--email E-mail
  • -p,--password 密码
  • -u,--username 用户名

logout

logs

查看docker日志:docker logs [container ID or NAMES]

  • --since timestamp 从某时间戳开始后的日志
  • -t,--timestamps 显示时间戳
  • --tail=all 行数字

network

pause

port

查看端口映射情况:docker port [NAME] 5000

ps

显示容器列表:docker ps [OPTIONS]

  • -a,--all 显示全部
  • -f,--filter=[] 基于条件的显示
  • --format 格式化显示
  • -l 显示最新的一个容器
  • -n=1 显示n个最新的容器
  • --no-trunc 非截取输出
  • q,--quiet 仅显示ID
  • -s,--size 显示完整大小

pull命令

下载镜像

push

提交镜像到镜像仓库:docker push [repository]

rename

restart

rm

rmi

清除镜像:docker rmi 镜像名

  • -f 强制删除
  • --no-prune 删除未标记的镜像

run命令

启动镜像,生成容器

  • -i 捕获标准输入输出
  • -t 分配一个终端或控制台
  • -d,--detach 后台运行
  • -h hostname
  • --ip ipv4地址
  • --ip6 ipv6地址
  • --link=[] 链接其它容器
  • --name 容器名称
  • --rm 退出时删除容器
  • -v,--volume=[] 绑定数据卷
  • --volumes-from=[] 从容器挂载数据卷
  • --ulimit=[] ulimit设置
  • -e,--env=[] 设置环境变量
  • -p 指定端口到端口的映射,可多个
  • -P 映射所有端口到容器的一个随机端口
  • -m 内存限制
  • 容器内执行exit,或Ctrl+d推出容器

save

search

搜索镜像:docker search 镜像名

start

stats

stop

tag

标记镜像:docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]

top

unpause

update

version

volume

wait

添加新评论