docker_compose_run.yaml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. command: docker compose run
  2. short: Run a one-off command on a service.
  3. long: "Runs a one-time command against a service. \n\nthe following command starts the `web` service and runs `bash` as its command:\n\n```console\n$ docker compose run web bash\n```\n\nCommands you use with run start in new containers with configuration defined by that of the service,\nincluding volumes, links, and other details. However, there are two important differences:\n\nFirst, the command passed by `run` overrides the command defined in the service configuration. For example, if the \n`web` service configuration is started with `bash`, then `docker compose run web python app.py` overrides it with \n`python app.py`.\n\nThe second difference is that the `docker compose run` command does not create any of the ports specified in the \nservice configuration. This prevents port collisions with already-open ports. If you do want the service’s ports \nto be created and mapped to the host, specify the `--service-ports`\n\n```console\n$ docker compose run --service-ports web python manage.py shell\n```\n\nAlternatively, manual port mapping can be specified with the `--publish` or `-p` options, just as when using docker run:\n\n```console\n$ docker compose run --publish 8080:80 -p 2022:22 -p 127.0.0.1:2021:21 web python manage.py shell\n```\n\nIf you start a service configured with links, the run command first checks to see if the linked service is running \nand starts the service if it is stopped. Once all the linked services are running, the run executes the command you \npassed it. For example, you could run:\n\n```console\n$ docker compose run db psql -h db -U docker\n```\n\nThis opens an interactive PostgreSQL shell for the linked `db` container.\n\nIf you do not want the run command to start linked containers, use the `--no-deps` flag:\n\n```console\n$ docker compose run --no-deps web python manage.py shell\n```\n\nIf you want to remove the container after running while overriding the container’s restart policy, use the `--rm` flag:\n\n```console\n$ docker compose run --rm web python manage.py db upgrade\n```\n\nThis runs a database upgrade script, and removes the container when finished running, even if a restart policy is \nspecified in the service configuration."
  4. usage: docker compose run [options] [-v VOLUME...] [-p PORT...] [-e KEY=VAL...] [-l KEY=VALUE...] SERVICE [COMMAND] [ARGS...]
  5. pname: docker compose
  6. plink: docker_compose.yaml
  7. options:
  8. - option: detach
  9. shorthand: d
  10. value_type: bool
  11. default_value: "false"
  12. description: Run container in background and print container ID
  13. deprecated: false
  14. experimental: false
  15. experimentalcli: false
  16. kubernetes: false
  17. swarm: false
  18. - option: entrypoint
  19. value_type: string
  20. description: Override the entrypoint of the image
  21. deprecated: false
  22. experimental: false
  23. experimentalcli: false
  24. kubernetes: false
  25. swarm: false
  26. - option: env
  27. shorthand: e
  28. value_type: stringArray
  29. default_value: '[]'
  30. description: Set environment variables
  31. deprecated: false
  32. experimental: false
  33. experimentalcli: false
  34. kubernetes: false
  35. swarm: false
  36. - option: labels
  37. shorthand: l
  38. value_type: stringArray
  39. default_value: '[]'
  40. description: Add or override a label
  41. deprecated: false
  42. experimental: false
  43. experimentalcli: false
  44. kubernetes: false
  45. swarm: false
  46. - option: name
  47. value_type: string
  48. description: ' Assign a name to the container'
  49. deprecated: false
  50. experimental: false
  51. experimentalcli: false
  52. kubernetes: false
  53. swarm: false
  54. - option: no-TTY
  55. shorthand: T
  56. value_type: bool
  57. default_value: "false"
  58. description: |
  59. Disable pseudo-noTty allocation. By default docker compose run allocates a TTY
  60. deprecated: false
  61. experimental: false
  62. experimentalcli: false
  63. kubernetes: false
  64. swarm: false
  65. - option: no-deps
  66. value_type: bool
  67. default_value: "false"
  68. description: Don't start linked services.
  69. deprecated: false
  70. experimental: false
  71. experimentalcli: false
  72. kubernetes: false
  73. swarm: false
  74. - option: publish
  75. shorthand: p
  76. value_type: stringArray
  77. default_value: '[]'
  78. description: Publish a container's port(s) to the host.
  79. deprecated: false
  80. experimental: false
  81. experimentalcli: false
  82. kubernetes: false
  83. swarm: false
  84. - option: rm
  85. value_type: bool
  86. default_value: "false"
  87. description: Automatically remove the container when it exits
  88. deprecated: false
  89. experimental: false
  90. experimentalcli: false
  91. kubernetes: false
  92. swarm: false
  93. - option: service-ports
  94. value_type: bool
  95. default_value: "false"
  96. description: |
  97. Run command with the service's ports enabled and mapped to the host.
  98. deprecated: false
  99. experimental: false
  100. experimentalcli: false
  101. kubernetes: false
  102. swarm: false
  103. - option: use-aliases
  104. value_type: bool
  105. default_value: "false"
  106. description: |
  107. Use the service's network useAliases in the network(s) the container connects to.
  108. deprecated: false
  109. experimental: false
  110. experimentalcli: false
  111. kubernetes: false
  112. swarm: false
  113. - option: user
  114. shorthand: u
  115. value_type: string
  116. description: Run as specified username or uid
  117. deprecated: false
  118. experimental: false
  119. experimentalcli: false
  120. kubernetes: false
  121. swarm: false
  122. - option: volume
  123. shorthand: v
  124. value_type: stringArray
  125. default_value: '[]'
  126. description: Bind mount a volume.
  127. deprecated: false
  128. experimental: false
  129. experimentalcli: false
  130. kubernetes: false
  131. swarm: false
  132. - option: workdir
  133. shorthand: w
  134. value_type: string
  135. description: Working directory inside the container
  136. deprecated: false
  137. experimental: false
  138. experimentalcli: false
  139. kubernetes: false
  140. swarm: false
  141. deprecated: false
  142. experimental: false
  143. experimentalcli: false
  144. kubernetes: false
  145. swarm: false