title: Gitlab CI - Deploy docker-compose.yml on dev-server, test and deploy to PD
body: <p>I'm completely new to Gitlab CI but started to read the documentation. Before actual building it, I want to check if it is a good idea to proceed as planned:</p>
  <p>I have a docker-compose file and several Dockerfiles in a Gitlab repository. The docker-compose file consists of many images which are dependent on each other. We have two docker servers, one <em>prod server</em> and one <em>dev server</em>. We want to achieve the following:</p>
  <ol>
  <li>By a trigger (manually or a commit), we want to spin-down (via  <code>docker-compose down</code>) the containers on the <em>dev server</em></li>
  <li>Checkout the latest / current version of the repository (containing the docker-compose.yml and the Dockerfiles)</li>
  <li>Start all containers on <em>dev server</em> (via <code>docker-compose up -d</code>)</li>
  <li>[for later, needs to be defined] Start a test</li>
  <li>If test was successful or by manual interaction (click on a button), the environment should be deployed on the <em>prod server</em> (meaning step 1, 2 and 3 on <em>prod server</em>).</li>
  </ol>
  <p>Does anything speak against this approach? The main issue I currently have is, that I don't know how to &quot;use&quot; / &quot;reference&quot; my existing servers. So I don't want to have the usual approach (creating a new isolated docker container, test the software and throw away) but I want to do it as described above.</p>
  <p>Thanks for your help!</p>
  <h1>Edit</h1>
  <p>After doing some additional research, I feel the need to add some things: From what I understand, normally a Docker container is spinned up during CI/CD pipeline to test your application. Since I'm actually testing a whole stack of containers / a docker-compose file which has certain requirements to the docker host system, I would need to use something like docker in docker and deploy my stack there. However, in the first stage I would like to use the existing docker server since my &quot;stack&quot; needs to be adjusted in order to be created from scratch dynamically.</p>
  <p>The reason why the containers have requirements to the host system is the fact, that we use Docker in this scenario as an <em>infrastructure tool</em>. So instead of VMs, we use Docker containers. The result is a complete environment of an enterprise application where the different services (management interfaces, repositories etc.) are individual containers.</p>
  <p>Hope this helps. If something is unclear, just ask.</p>