title: Gitlab Runner Removed Cache (files/container)
body: <p>My "problem" is when i run my ci on my remote docker machine, the gitlab-runner leaves the container that has been used there without to remove them. The other thing is that the project sources are also given when you show into the volumes folder. </p>
  
  <p>Does someone has maybe ideas how i can change it, that the container and project sources will be deleted after ci-pipeline run?</p>
  
  <p>Good Regards,
  cRUSH</p>
  
  <pre><code>stages:
  - Build
  - Testing
  - Execute
  - Publish
  - CleanUp
  
  build_cleanup:
      only:
          - master
      stage: Build
      script:
          - "dotnet clean"
          - (if  [ $(docker ps -a | grep $CONTAINER_NAME | cut -d " " -f1) ]; then echo $(docker rm -f $CONTAINER_NAME); else echo OK; fi;);
          - (if  [ $(docker volume ls -qf dangling=true) ]; then echo $(docker volume prune -f); else echo OK; fi;);
      when: on_failure
  
  testing_cleanup:
      only:
          - master
      stage: Testing
      script:
          - "dotnet clean"
          - (if  [ $(docker ps -a | grep $CONTAINER_NAME | cut -d " " -f1) ]; then echo $(docker rm -f $CONTAINER_NAME); else echo OK; fi;);
          - (if  [ $(docker volume ls -qf dangling=true) ]; then echo $(docker volume prune -f); else echo OK; fi;);
      when: on_failure
  
  excecute_cleanup:
      only:
          - master
      stage: Execute
      script:
          - "dotnet clean"
          - (if  [ $(docker ps -a | grep $CONTAINER_NAME | cut -d " " -f1) ]; then echo $(docker rm -f $CONTAINER_NAME); else echo OK; fi;);
          - (if  [ $(docker volume ls -qf dangling=true) ]; then echo $(docker volume prune -f); else echo OK; fi;);
      when: on_failure
  
  publish_cleanup:
      only:
          - master
      stage: Publish
      script:
          - "dotnet clean"
          - (if  [ $(docker ps -a | grep $CONTAINER_NAME | cut -d " " -f1) ]; then echo $(docker rm -f $CONTAINER_NAME); else echo OK; fi;);
          - (if  [ $(docker volume ls -qf dangling=true) ]; then echo $(docker volume prune -f); else echo OK; fi;);
      when: on_failure
  
  cleanup_jobs:
      only:
          - master
      stage: CleanUp
      script: 
          - "dotnet clean"
          - (if  [ $(docker ps -a | grep $CONTAINER_NAME | cut -d " " -f1) ]; then echo $(docker rm -f $CONTAINER_NAME); else echo OK; fi;);
          - (if  [ $(docker volume ls -qf dangling=true) ]; then echo $(docker volume prune -f); else echo OK; fi;);
      when: always
  </code></pre>
  
  <p>This is my current configuration.</p>