docker_compose_run.yaml 5.9 KB

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