diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/docker/compose%2Fproduction%2Findex.html | |
new repository
Diffstat (limited to 'devdocs/docker/compose%2Fproduction%2Findex.html')
| -rw-r--r-- | devdocs/docker/compose%2Fproduction%2Findex.html | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/devdocs/docker/compose%2Fproduction%2Findex.html b/devdocs/docker/compose%2Fproduction%2Findex.html new file mode 100644 index 00000000..3b3adfd6 --- /dev/null +++ b/devdocs/docker/compose%2Fproduction%2Findex.html @@ -0,0 +1,13 @@ +<h1>Use Compose in production</h1> + +<p>When you define your app with Compose in development, you can use this definition to run your application in different environments such as CI, staging, and production.</p> <p>The easiest way to deploy an application is to run it on a single server, similar to how you would run your development environment. If you want to scale up your application, you can run Compose apps on a Swarm cluster.</p> <h3 id="modify-your-compose-file-for-production">Modify your Compose file for production</h3> <p>You probably need to make changes to your app configuration to make it ready for production. These changes may include:</p> <ul> <li>Removing any volume bindings for application code, so that code stays inside the container and can’t be changed from outside</li> <li>Binding to different ports on the host</li> <li>Setting environment variables differently, such as reducing the verbosity of logging, or to specify settings for external services such as an email server</li> <li>Specifying a restart policy like <code class="language-plaintext highlighter-rouge">restart: always</code> to avoid downtime</li> <li>Adding extra services such as a log aggregator</li> </ul> <p>For this reason, consider defining an additional Compose file, say <code class="language-plaintext highlighter-rouge">production.yml</code>, which specifies production-appropriate configuration. This configuration file only needs to include the changes you’d like to make from the original Compose file. The additional Compose file can be applied over the original <code class="language-plaintext highlighter-rouge">docker-compose.yml</code> to create a new configuration.</p> <p>Once you’ve got a second configuration file, tell Compose to use it with the <code class="language-plaintext highlighter-rouge">-f</code> option:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker-compose -f docker-compose.yml -f production.yml up -d +</pre></div> <p>See <a href="../extends/index#different-environments">Using multiple compose files</a> for a more complete example.</p> <h3 id="deploying-changes">Deploying changes</h3> <p>When you make changes to your app code, remember to rebuild your image and recreate your app’s containers. To redeploy a service called <code class="language-plaintext highlighter-rouge">web</code>, use:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker-compose build web +$ docker-compose up --no-deps -d web +</pre></div> <p>This first rebuilds the image for <code class="language-plaintext highlighter-rouge">web</code> and then stop, destroy, and recreate <em>just</em> the <code class="language-plaintext highlighter-rouge">web</code> service. The <code class="language-plaintext highlighter-rouge">--no-deps</code> flag prevents Compose from also recreating any services which <code class="language-plaintext highlighter-rouge">web</code> depends on.</p> <h3 id="running-compose-on-a-single-server">Running Compose on a single server</h3> <p>You can use Compose to deploy an app to a remote Docker host by setting the <code class="language-plaintext highlighter-rouge">DOCKER_HOST</code>, <code class="language-plaintext highlighter-rouge">DOCKER_TLS_VERIFY</code>, and <code class="language-plaintext highlighter-rouge">DOCKER_CERT_PATH</code> environment variables appropriately.</p> <p>Once you’ve set up your environment variables, all the normal <code class="language-plaintext highlighter-rouge">docker-compose</code> commands work with no further configuration.</p> <h2 id="compose-documentation">Compose documentation</h2> <ul> <li><a href="../index">User guide</a></li> <li><a href="../install/index">Installing Compose</a></li> <li><a href="../gettingstarted/index">Getting Started</a></li> <li><a href="../reference/index">Command line reference</a></li> <li><a href="../compose-file/index">Compose file reference</a></li> <li><a href="../samples-for-compose/index">Sample apps with Compose</a></li> </ul> +<p><a href="https://docs.docker.com/search/?q=compose">compose</a>, <a href="https://docs.docker.com/search/?q=orchestration">orchestration</a>, <a href="https://docs.docker.com/search/?q=containers">containers</a>, <a href="https://docs.docker.com/search/?q=production">production</a></p> +<div class="_attribution"> + <p class="_attribution-p"> + © 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/production/" class="_attribution-link">https://docs.docker.com/compose/production/</a> + </p> +</div> |
