title: How to clone docker service into a new one (docker swarm)
body: <p>I'm using Docker Swarm and Portainer.</p>
  
  <p>To test services with different images I need to clone a docker swarm service, all the hosts, mounts, labels, secrets etc must be in the new service too. This is a hard thing to do by hand, because some services could have many environment vars and Portainer don't help me so much with this.</p>
  
  <p>I need to clone my whole service website_develop and run it in a different Traefik host and docker image.</p>
  
  <hr>
  
  <h2>Storytelling about</h2>
  
  <p>My docker swarm services are based on repo's branch.</p>
  
  <p>E.g: website repo have the following services: website_master, website_develop.</p>
  
  <p>I must be able to clone the website_develop service and execute it with a feature/ branch. </p>
  
  <p>Developer A (aka D.A) is working on feature/a in the website project.</p>
  
  <p>Developer B (aka D.B) is working on feature/b in the website project.</p>
  
  <p>D.A just merged his feature to stagging environment (website_develop) because it's done.</p>
  
  <p>D.B wants to test his feature in the stagging environment. But he can't merge to website_develop because it would be merged to master without being done and cause errors (D.B will merge develop to master soon).</p>
  
  <p>GDSC will clone the service website_develop with a new name based on the branch's name with the new docker image URL and a new Traefik host.</p>
  
  <p>D.B publishes his feature/a to the repository (git flow feature publish).</p>
  
  <p>Git repository (gitlab, github) will trigger Jenkins with the update.</p>
  
  <p>Jenkins will build the Dockerfile and then create a new service or update a created service.</p>