information
- info
- version
status
- inspect 容器所有信息
- top 容器内进程
- stats 容器资源
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
my-registry 0.00% 3.637 MiB / 1.795 GiB 0.20% 44.7 MB / 142 kB 0 B / 44.9 MB 0
- logs
docker logs -f --tail 100 [containerName]
run
- -v
会绕过联合文件系统,挂载主机的路径。无论是否指定挂载路径,删除container后volume都会保留。
- --rm 退出后删除
- --restart=always 无论什么原因(docker stop除外),容器退出都立即重启
- --restart=on-failure:3 exit值非0时重启,做多重启3次
- --attach
- --entrypoint 替换容器默认的entrypoint
- --cpu-shares=1000 cpu权重
- --cpu-quota
- --memory=1024M (-m) 内存资源配额
- --add-host
- --dns
- --dns-search
- --health-cmd --health-interval --health-retries --health-timeout
- --log-driver 默认json-file
- --network host|none|bridge等
- --network-alias
- --env (-e)
- --env-file
- --expose
即使run或者Dockerfile中没有expose这个port,依然可以把port暴露到host上。
- --link
会把link容器内的环境变量以不同的变量名注入到当前容器
会在目标容器上添加相关主机条目到/etc/hosts
/etc/host文件在源容器被重启之后会自动更新 IP 地址,而环境变量中的 IP 地址则不会自动更新的。
CLIENTPORT=26479
REDIS6479_ENV_CLIENTPORT=6479
REDIS6479_PORT=tcp://172.17.51.2:6379
REDIS6479_PORT_6379_TCP_ADDR=172.17.51.2
MASTERPORT=6479
REDIS6479_PORT_6379_TCP_PORT=6379
REDIS6479_PORT_6379_TCP_PROTO=tcp
REDIS6479_ENV_MASTERPORT=6479
REDIS6479_PORT_6379_TCP=tcp://172.17.51.2:6379
build commit
docker commit -a "amourlinux" -m "myredis" -p 244a34993195 amourlinux/redis:0.0.1
docket build --no-cache -t "<tag>" .
-a 作者,-m commit message,-p commit时pause
--no-cache 不使用缓存,重新构建
tar
docker save amourlinux/redis:0.0.1 > redis.tar
docker load < redis.tar
address udp
docker run -p 127.0.0.1:53:5353/udp <image> <cmd>
remove
docker rm
docker rm -f
docker rm -f `docker ps -aq` (删除所有容器)
docker rmi
docker rmi -f
docker rm -v `docker ps -aq -f status=exited` (删除所有stop的容器)
-f, --filter=[]
Filter output based on these conditions:
- exited=<int> an exit code of <int>
- label=<key> or label=<key>=<value>
- status=(created|restarting|running|paused|exited|dead)
- name=<string> a container's name
- id=<ID> a container's ID
- is-task=(true|false) - containers that are a task (part of a service managed by swarm)
- before=(<container-name>|<container-id>)
- since=(<container-name>|<container-id>)
- ancestor=(<image-name>[:tag]|<image-id>| ⟨image@digest⟩) - containers created from an image or a descendant.
- volume=(<volume-name>|<mount-point-destination>)
- network=(<network-name>|<network-id>) - containers connected to the provided network
- health=(starting|healthy|unhealthy|none) - filters containers based on healthcheck status
update
docker update 更新container参数配置