🎨
Docker
  • Docker入门
  • Docker overview
    • 隔离与限制
    • copy-on-write(CoW: 写时复制)
    • docker中的联合文件系统
    • Docker存储
      • tmpfs mounts
      • volume
      • bind mounts
    • Docker网络
      • host模式
      • bridge模式
        • default bridge模式
        • User-defined bridge模式
      • none模式
      • container模式
  • 容器监控方式
    • prometheus + grafana+cAdvisor监控容器
  • Dockerfile指令
    • Usage
    • BuildKit
    • Format
    • Parser directives
      • syntax
      • escape
    • Environment replacement
    • FROM
      • 了解ARG和FROM之间的交互方式
    • .dockerignore file
    • RUN
    • CMD
    • COPY
    • ADD
    • ENV
    • WORKDIR
    • ARG
      • Impact on build caching(对构建缓存的影响)
      • Default(默认值)
      • Scope(作用域)
      • Using ARG Variables(使用ARG变量)
      • Predefined ARGS(预先定义好的ARG变量)
      • Automatic platform ARGs in the global scope(全局作用域中自动化平台的ARGS)
    • STOPSIGNAL
    • HEALTHCHECK
    • SHELL
    • ONBUILD
    • Dockerfile示例
    • LABEL
    • MAINTAINER (deprecated)
    • EXPOSE
    • ENTRYPOINT
      • Shell形式的ENTRYPOINT示例
      • 理解CMD和ENTRYPOINT是如何交互的
    • VOLUME
    • USER
  • docker-compose.yaml文件中常用指令
    • compose文件结构和示例
    • 服务配置参考
      • build
        • dockerfile
        • context
        • shm_size
        • network
        • labels
        • cache_from
        • args
        • target
      • cap_add, cap_drop
      • cgroup_parent
      • command
      • configs
        • 短语法形式
        • 长语法形式
      • container_name
      • credential_spec
        • EXAMPLE GMSA CONFIGURATION
      • depends_on
      • deploy
        • endpoint_mode
        • labels
        • mode
        • placement
        • max_replicas_per_node
        • replicas
        • resource
        • restart_policy
        • rollback_config
        • Update_config
        • Not supported for docker stack deploy
      • devices
      • dns
      • dns_search
      • entrypoint
      • env_file
      • environment
      • expose
      • external_links
      • extra_hosts
      • healthcheck
      • image
      • init
      • isolation
      • labels
      • links
      • logging
      • network_mode
      • networks
        • alias
        • IPV4_ADDRESS, IPV6_ADDRESS
      • pid
      • ports
        • 长语法
        • 短语法
      • profiles
      • restart
      • secrets
        • 长语法
        • 短语法
      • security_opt
      • stop_grace_period
      • stop_signal
      • sysctls
      • tmpfs
      • ulimits
      • userns_mode
      • volumes
        • 长语法
        • 短语法
        • VOLUMES FOR SERVICES, SWARMS, AND STACK FILES
      • domainname, hostname, ipc, mac_address, privileged, read_only, shm_size, stdin_open, tty, user, work
      • Specifying durations
      • Specifying byte values
      • Volume configuration reference
        • driver
        • driver_opts
        • external
        • labels
        • name
      • Network configuration reference
        • name
        • external
        • labels
        • internal
        • ipam
        • enable_ipv6
        • driver
          • overlay
          • bridge
          • host或者none
        • driver_opts
        • attachable
      • configs configuration reference
      • secrets configuration reference
      • Variable substitution
      • Extension fields
  • docker-compose示例
    • WordPress
    • PostgreSQL
    • Django和PostgreSQL
    • Rails和PostgreSQL
  • Dockerfile最佳实践
Powered by GitBook
On this page

Was this helpful?

  1. docker-compose.yaml文件中常用指令
  2. 服务配置参考
  3. configs

长语法形式

Previous短语法形式Nextcontainer_name

Last updated 4 years ago

Was this helpful?

对于如何定义config,长语法提供了更加细粒度的方式。

  • source:Docker中已经存在的config的名称

  • target:被挂载到服务的任务容器上的路径和文件名。如果没有指定,默认是/<source>

  • uid和gid:在服务的任务容器中,uid和gid代表的用户和用户组拥有被挂载的config文件。如果没有指定,默认两个值都为0。不支持windows系统。

  • mode:被挂载到服务的任务容器中的文件权限,以八进制命名。例如0444代表只读。默认是0444权限。配置(Configs)无法被写入,因为它们被挂载在临时的文件系统中。因此,如果你设置写的权限位,该权限位会被忽视。可以设置可执行的权限位。如果不熟悉Unix文件权限模式,参考。

下面示例中,my_config被设置为redis_config, 权限设置为0440,uid和gid设置为103。redis服务没有权限访问my_other_config配置。

 version: "3.8"
 services:
   redis:
     image: redis:latest
     deploy:
       replicas: 1
     configs:
       - source: my_config
         target: /redis_config
         uid: '103'
         gid: '103'
         mode: 0440
 configs:
   my_config:
     file: ./my_config.txt
   my_other_config:
     external: true

可以同时授权访问多个服务,也可以长语法和短语法形式混用。定义了配置以后,不会隐示授权一个服务去使用它。

权限计算