blob: 38aad034671092e02ece421a9aae7a133515fb59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<h1>Deploy a service to the swarm</h1>
<p>After you <a href="../create-swarm/index">create a swarm</a>, you can deploy a service to the swarm. For this tutorial, you also <a href="../add-nodes/index">added worker nodes</a>, but that is not a requirement to deploy a service.</p> <ol> <li> <p>Open a terminal and ssh into the machine where you run your manager node. For example, the tutorial uses a machine named <code class="language-plaintext highlighter-rouge">manager1</code>.</p> </li> <li> <p>Run the following command:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker service create --replicas 1 --name helloworld alpine ping docker.com
9uk4639qpg7npwf3fn2aasksr
</pre></div> <ul> <li>The <code class="language-plaintext highlighter-rouge">docker service create</code> command creates the service.</li> <li>The <code class="language-plaintext highlighter-rouge">--name</code> flag names the service <code class="language-plaintext highlighter-rouge">helloworld</code>.</li> <li>The <code class="language-plaintext highlighter-rouge">--replicas</code> flag specifies the desired state of 1 running instance.</li> <li>The arguments <code class="language-plaintext highlighter-rouge">alpine ping docker.com</code> define the service as an Alpine Linux container that executes the command <code class="language-plaintext highlighter-rouge">ping docker.com</code>.</li> </ul> </li> <li> <p>Run <code class="language-plaintext highlighter-rouge">docker service ls</code> to see the list of running services:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker service ls
ID NAME SCALE IMAGE COMMAND
9uk4639qpg7n helloworld 1/1 alpine ping docker.com
</pre></div> </li> </ol> <h2 id="whats-next">What’s next?</h2> <p>Now you’ve deployed a service to the swarm, you’re ready to <a href="../inspect-service/index">inspect the service</a>.</p>
<p><a href="https://docs.docker.com/search/?q=tutorial">tutorial</a>, <a href="https://docs.docker.com/search/?q=cluster%20management">cluster management</a>, <a href="https://docs.docker.com/search/?q=swarm%20mode">swarm mode</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/engine/swarm/swarm-tutorial/deploy-service/" class="_attribution-link">https://docs.docker.com/engine/swarm/swarm-tutorial/deploy-service/</a>
</p>
</div>
|