summaryrefslogtreecommitdiff
path: root/devdocs/docker/compose%2Fcli-command-compatibility%2Findex.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/docker/compose%2Fcli-command-compatibility%2Findex.html
new repository
Diffstat (limited to 'devdocs/docker/compose%2Fcli-command-compatibility%2Findex.html')
-rw-r--r--devdocs/docker/compose%2Fcli-command-compatibility%2Findex.html37
1 files changed, 37 insertions, 0 deletions
diff --git a/devdocs/docker/compose%2Fcli-command-compatibility%2Findex.html b/devdocs/docker/compose%2Fcli-command-compatibility%2Findex.html
new file mode 100644
index 00000000..202dd1a9
--- /dev/null
+++ b/devdocs/docker/compose%2Fcli-command-compatibility%2Findex.html
@@ -0,0 +1,37 @@
+<h1>Compose command compatibility with docker-compose</h1>
+
+<p>The <code class="language-plaintext highlighter-rouge">compose</code> command in the Docker CLI supports most of the <code class="language-plaintext highlighter-rouge">docker-compose</code> commands and flags. It is expected to be a drop-in replacement for <code class="language-plaintext highlighter-rouge">docker-compose</code>.</p> <p>If you see any Compose functionality that is not available in the <code class="language-plaintext highlighter-rouge">compose</code> command, create an issue in the <a href="https://github.com/docker/compose/issues" target="_blank" rel="noopener" class="_">Compose</a> GitHub repository, so we can prioritize it.</p> <h2 id="commands-or-flags-not-yet-implemented">Commands or flags not yet implemented</h2> <p>The following commands have not been implemented yet, and may be implemented at a later time. Let us know if these commands are a higher priority for your use cases.</p> <p><code class="language-plaintext highlighter-rouge">compose build --memory</code>: This option is not yet supported by buildkit. The flag is currently supported, but is hidden to avoid breaking existing Compose usage. It does not have any effect.</p> <h2 id="flags-that-will-not-be-implemented">Flags that will not be implemented</h2> <p>The list below includes the flags that we are not planning to support in Compose in the Docker CLI, either because they are already deprecated in <code class="language-plaintext highlighter-rouge">docker-compose</code>, or because they are not relevant for Compose in the Docker CLI.</p> <ul> <li>
+<code class="language-plaintext highlighter-rouge">compose ps --filter KEY-VALUE</code> Not relevant due to its complicated usage with the <code class="language-plaintext highlighter-rouge">service</code> command and also because it is not documented properly in <code class="language-plaintext highlighter-rouge">docker-compose</code>.</li> <li>
+<code class="language-plaintext highlighter-rouge">compose rm --all</code> Deprecated in docker-compose.</li> <li>
+<code class="language-plaintext highlighter-rouge">compose scale</code> Deprecated in docker-compose (use <code class="language-plaintext highlighter-rouge">compose up --scale</code> instead)</li> </ul> <p>Global flags:</p> <ul> <li>
+<code class="language-plaintext highlighter-rouge">--compatibility</code> has been resignified Docker Compose V2. This now means that in the command running V2 will behave as V1 used to do. <ul> <li>One difference is in the word separator on container names. V1 used to use <code class="language-plaintext highlighter-rouge">_</code> as separator while V2 uses <code class="language-plaintext highlighter-rouge">-</code> to keep the names more hostname friendly. So when using <code class="language-plaintext highlighter-rouge">--compatibility</code> Docker Compose should use <code class="language-plaintext highlighter-rouge">_</code> again. Just make sure to stick to one of them otherwise Docker Compose will not be able to recognize the container as an instance of the service.</li> </ul> </li> </ul> <h2 id="config-command">Config command</h2> <p>The config command is intended to show the configuration used by Docker Compose to run the actual project. As we know, at some parts of the Compose file have a short and a long format. For example, the <code class="language-plaintext highlighter-rouge">ports</code> entry. In the example below we can see the config command expanding the <code class="language-plaintext highlighter-rouge">ports</code> section:</p> <p>docker-compose.yml:</p> <div class="highlight"><pre class="highlight" data-language="">services:
+ web:
+ image: nginx
+ ports:
+ - 80:80
+</pre></div> <p>With <code class="language-plaintext highlighter-rouge">$ docker compose config</code> the output turns into:</p> <div class="highlight"><pre class="highlight" data-language="">services:
+ web:
+ image: nginx
+ networks:
+ default: null
+ ports:
+ - mode: ingress
+ target: 80
+ published: 80
+ protocol: tcp
+networks:
+ default:
+ name: workspace_default
+</pre></div> <p>The result above is a full size configuration of what will be used by Docker Compose to run the project.</p> <h2 id="new-commands-introduced-in-compose-v2">New commands introduced in Compose v2</h2> <h3 id="copy">Copy</h3> <p>The <code class="language-plaintext highlighter-rouge">cp</code> command is intended to copy files or folders between service containers and the local filesystem.<br> This command is a bidirectional command, we can copy <strong>from</strong> or <strong>to</strong> the service containers.</p> <p>Copy a file from a service container to the local filesystem:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker compose cp my-service:~/path/to/myfile ~/local/path/to/copied/file
+</pre></div> <p>We can also copy from the local filesystem to all the running containers of a service:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker compose cp --all ~/local/path/to/source/file my-service:~/path/to/copied/file
+</pre></div> <h3 id="list">List</h3> <p>The ls command is intended to list the Compose projects. By default, the command only lists the running projects, we can use flags to display the stopped projects, to filter by conditions and change the output to <code class="language-plaintext highlighter-rouge">json</code> format for example.</p> <div class="highlight"><pre class="highlight" data-language="">$ docker compose ls --all --format json
+[{"Name":"dockergithubio","Status":"exited(1)","ConfigFiles":"/path/to/docker.github.io/docker-compose.yml"}]
+</pre></div> <h2 id="use---project-name-with-compose-commands">Use <code class="language-plaintext highlighter-rouge">--project-name</code> with Compose commands</h2> <p>With the GA version of Compose, you can run some commands:</p> <ul> <li>outside of directory containing the project compose file</li> <li>or without specifying the path of the Compose with the <code class="language-plaintext highlighter-rouge">--file</code> flag</li> <li>or without specifying the project directory with the <code class="language-plaintext highlighter-rouge">--project-directory</code> flag</li> </ul> <p>When a compose project has been loaded once, we can just use the <code class="language-plaintext highlighter-rouge">-p</code> or <code class="language-plaintext highlighter-rouge">--project-name</code> to reference it:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker compose -p my-loaded-project restart my-service
+</pre></div> <p>This option works with the <code class="language-plaintext highlighter-rouge">start</code>, <code class="language-plaintext highlighter-rouge">stop</code>, <code class="language-plaintext highlighter-rouge">restart</code> and <code class="language-plaintext highlighter-rouge">down</code> commands.</p>
+<p><a href="https://docs.docker.com/search/?q=documentation">documentation</a>, <a href="https://docs.docker.com/search/?q=docs">docs</a>, <a href="https://docs.docker.com/search/?q=docker">docker</a>, <a href="https://docs.docker.com/search/?q=compose">compose</a>, <a href="https://docs.docker.com/search/?q=containers">containers</a></p>
+<div class="_attribution">
+ <p class="_attribution-p">
+ &copy; 2019 Docker, Inc.<br>Licensed under the Apache License, Version 2.0.<br>Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>Docker, Inc. and other parties may also have trademark rights in other terms used herein.<br>
+ <a href="https://docs.docker.com/compose/cli-command-compatibility/" class="_attribution-link">https://docs.docker.com/compose/cli-command-compatibility/</a>
+ </p>
+</div>