正如johnharris85所说。
到目前为止(17.12)docker 还没有 API 来编辑容器的大多数选项。
我们唯一能做的就是编辑磁盘上的配置文件:
一般来说,配置位于文件夹中/var/lib/docker/containers/<containerID>*/
编辑它们,立即重新启动 docker 服务,新的配置将加载。
// 在 docker 17.12 中测试
另请参阅: https ://stackoverflow.com/a/49371983/4896468
// 找出(config.v2.json 的)目录
dirname `docker inspect $container_name | jq '.[].HostnamePath' -r`
Run Code Online (Sandbox Code Playgroud)
Synology NAS码头工人最近我意识到 docker cmd 能够Synology NAS DSM system
通过 cmdline 或 webgui 编辑容器设置(无需重新创建它,或完全重新启动 docker 服务)
这是docker update差异:
$ docker更新--帮助
用法: docker update [选项] CONTAINER [CONTAINER...]
更新一个或多个容器的配置
选项:
--blkio-weight uint16 块 IO(相对权重),在 10 到 1000 之间,或 0 禁用(默认 0)
+ --cap-add list 添加 Linux 功能
+ --cap-drop list 删除 Linux 功能
--cpu-period int 限制CPU CFS(完全公平调度程序)周期
--cpu-quota int 限制CPU CFS(完全公平调度程序)配额
--cpu-rt-period int 限制CPU实时周期(以微秒为单位)
--cpu-rt-runtime int 限制CPU实时运行时间(以微秒为单位)
-c, --cpu-shares int CPU 份额(相对权重)
--cpus 十进制 CPU 数量
--cpuset-cpus string 允许执行的 CPU (0-3, 0,1)
--cpuset-mems 允许执行的字符串 MEM (0-3, 0,1)
+ -e, --env list 设置环境变量
+ --env-file list 读入环境变量文件
--kernel-memory bytes 内核内存限制
+ --link list 添加到另一个容器的链接
-m, --memory bytes 内存限制
--memory-reservation bytes 内存软限制
--memory-swap bytes 交换限制等于内存加交换:“-1”以启用无限制交换
--pids-limit int 调整容器 pid 限制(设置 -1 表示无限制)
+ --privileged 赋予此容器扩展权限
+ -p, --publish list 将容器的端口发布到主机
--restart string 容器退出时应用的重新启动策略
+ -v, --volume list 绑定挂载卷

--
我不知道从哪里可以获得这个增强版的 docker。
希望有一天这可以在正式版本中实现。
顺便说一句:DSM webui 是我用过的最强大的 docker webui。
你不仅可以看到它的UI,还可以看到定制的docker服务。
//也许有一天,实现一个类似的 docker ui。
live-restore现在docker守护进程有一个live-restore选项,
可以在不停止其他容器的情况下重新启动守护进程。
它让生活更轻松。
$ docker update --help
Usage: docker update [OPTIONS] CONTAINER [CONTAINER...]
Update configuration of one or more containers
Options:
--blkio-weight uint16 Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
+ --cap-add list Add Linux capabilities
+ --cap-drop list Drop Linux capabilities
--cpu-period int Limit CPU CFS (Completely Fair Scheduler) period
--cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota
--cpu-rt-period int Limit the CPU real-time period in microseconds
--cpu-rt-runtime int Limit the CPU real-time runtime in microseconds
-c, --cpu-shares int CPU shares (relative weight)
--cpus decimal Number of CPUs
--cpuset-cpus string CPUs in which to allow execution (0-3, 0,1)
--cpuset-mems string MEMs in which to allow execution (0-3, 0,1)
+ -e, --env list Set environment variables
+ --env-file list Read in a file of environment variables
--kernel-memory bytes Kernel memory limit
+ --link list Add link to another container
-m, --memory bytes Memory limit
--memory-reservation bytes Memory soft limit
--memory-swap bytes Swap limit equal to memory plus swap: '-1' to enable unlimited swap
--pids-limit int Tune container pids limit (set -1 for unlimited)
+ --privileged Give extended privileges to this container
+ -p, --publish list Publish a container's port(s) to the host
--restart string Restart policy to apply when a container exits
+ -v, --volume list Bind mount a volume
https://docs.docker.com/config/containers/live-restore/
小智 2
不,不可能编辑返回的“内置”配置和状态信息docker inspect。但是,如果您想添加信息,那么docker inspect您可以考虑向图像/容器添加标签,然后进行内省(因为标签信息由 返回docker inspect)。
| 归档时间: |
|
| 查看次数: |
11492 次 |
| 最近记录: |