title: Error while deploying application: persistentvolumeclaims already exists
body: <p>I have a docker application which uses docker-compose, i want to deploy the project in openshift-3, so i'm using  <a href="https://kompose.io/" rel="nofollow noreferrer">kompose</a>.
  Here is my docker-compose file:-</p>
  
  <pre><code>version: '3'
  
  services:
    katana-db:
      image: postgres
      restart: always
      environment:
        POSTGRES_PASSWORD: *****
        POSTGRES_USER: *****
    backend:
      depends_on:
        - katana-db
      build:
        context: .
        dockerfile: dockerfile_uwsgi
      image: warrior_deployment_backend
      extra_hosts:
        - "example.com:100.0.0.201"
      volumes:
        - katana-secrets:/secrets
        - katana-static:/warriorframework_py3/static
        - katana-wapps:/warriorframework_py3/katana/wapps
        - katana-wui:/warriorframework_py3/katana/wui
      ports:
        - "4000:4000"
      environment:
        DB_HOST: katana-db
        DB_NAME: warrior
        DB_USER: *****
        DB_PASSWORD: *****
    migration:
      depends_on:
        - backend
      image: warrior_deployment_backend
      entrypoint: ["sh", "-c"]
      command: ["
        python /warriorframework_py3/katana/manage.py collectstatic --noinput;
        python /warriorframework_py3/katana/manage.py makemigrations;
        python /warriorframework_py3/katana/manage.py migrate;
        echo \"from django.contrib.auth import get_user_model; User = get_user_model(); x = User.objects.create_superuser('admin', '', 'warriorframework') if not User.objects.filter(username='admin').exists() else User.objects.get(username='admin'); x.set_password('warriorframework'); x.save()\" | python /warriorframework_py3/katana/manage.py shell;
        "]
      volumes:
        - katana-static:/warriorframework_py3/static
        - katana-wapps:/warriorframework_py3/katana/wapps
        - katana-wui:/warriorframework_py3/katana/wui
      environment:
        DB_HOST: katana-db
        DB_NAME: warrior
        DB_USER: warrior
        DB_PASSWORD: qwerty
    frontend:
      depends_on:
        - backend
      build:
        context: .
        dockerfile: dockerfile_nginx
      image: warrior_deployment_frontend
      volumes:
        - katana-static:/warriorframework_py3/static
        - nginx-secrets:/secrets
      ports:
        - "9443:8443"
      labels:
        kompose.service.expose: "true"
  
  volumes:
    katana-static:
      driver: local-persist
      driver_opts:
        mountpoint: /data/local-persist/data/warrior/katana-static
    katana-wapps:
      driver: local-persist
      driver_opts:
        mountpoint: /data/local-persist/data/warrior/wapps
    katana-wui:
      driver: local-persist
      driver_opts:
        mountpoint: /data/local-persist/data/warrior/wui
    nginx-secrets:
      driver: local-persist
      driver_opts:
        mountpoint: /data/local-persist/data/warrior/nginx-secrets
    katana-secrets:
      driver: local-persist
      driver_opts:
        mountpoint: /data/local-persist/data/warrior/katana-secrets
  </code></pre>
  
  <p>when i run: </p>
  
  <p><code>sudo kompose up --provider openshift</code></p>
  
  <p>The error is as follows:</p>
  
  <p><code>FATA Error while deploying application: persistentvolumeclaims "katana-static" already exists</code></p>
  
  <p>The full console logs are as follows:</p>
  
  <pre><code>INFO Building image 'warrior_deployment_backend' from directory 'warrior_docker_deployment'
  INFO Image 'warrior_deployment_backend' from directory 'warrior_docker_deployment' built successfully
  INFO Pushing image 'warrior_deployment_backend:latest'
  INFO Multiple authentication credentials detected. Will try each configuration.
  INFO Attempting authentication credentials 'docker-registry-default.router.default.svc.cluster.local
  INFO Successfully pushed image 'warrior_deployment_backend:latest'
  INFO Building image 'warrior_deployment_frontend' from directory 'warrior_docker_deployment'
  INFO Image 'warrior_deployment_frontend' from directory 'warrior_docker_deployment' built successfully
  INFO Pushing image 'warrior_deployment_frontend:latest' to registry 
  INFO Multiple authentication credentials detected. Will try each configuration.
  INFO Attempting authentication credentials 'docker-registry-default.router.default.svc.cluster.local
  INFO Successfully pushed image 'warrior_deployment_frontend:latest' 
  INFO We are going to create OpenShift DeploymentConfigs, Services and PersistentVolumeClaims for your Dockerized application.
  If you need different kind of resources, use the 'kompose convert' and 'oc create -f' commands instead.
  
  INFO Deploying application in "rak-warrior-ui" namespace
  INFO Successfully created Service: backend
  INFO Successfully created Service: frontend
  INFO Successfully created DeploymentConfig: backend
  INFO Successfully created ImageStream: backend
  INFO Successfully created PersistentVolumeClaim: katana-secrets of size 100Mi. If your cluster has dynamic storage provisioning, you don't have to do anything. Otherwise you have to create PersistentVolume to make PVC work
  INFO Successfully created PersistentVolumeClaim: katana-static of size 100Mi. If your cluster has dynamic storage provisioning, you don't have to do anything. Otherwise you have to create PersistentVolume to make PVC work
  INFO Successfully created PersistentVolumeClaim: katana-wapps of size 100Mi. If your cluster has dynamic storage provisioning, you don't have to do anything. Otherwise you have to create PersistentVolume to make PVC work
  INFO Successfully created PersistentVolumeClaim: katana-wui of size 100Mi. If your cluster has dynamic storage provisioning, you don't have to do anything. Otherwise you have to create PersistentVolume to make PVC work
  INFO Successfully created DeploymentConfig: frontend
  INFO Successfully created ImageStream: frontend
  INFO Successfully created Route: frontend
  FATA Error while deploying application: persistentvolumeclaims "katana-static" already exists
  
  </code></pre>
  
  <p>As per my observation/analysis, the error can be due to following:-</p>
  
  <p>kompose might be wrongly interpreting the shared volumes. If i explain this more clearly, it is like "katana-static" is a shared volume that is used by frontend,backend, and migration containers. kompose does the following steps(here I'm focusing only on shared volume: katana-static)</p>
  
  <ol>
  <li>The kompose up will read the docker-compose.yml</li>
  <li>Now the first container is backend, so there it finds katana-static under volumes, so it creates the volume.</li>
  <li>Next it goes to next container and finds katana-static again, so it tries to create again</li>
  <li>Since it tries to create the shared persistent volume katana-static again, which already exists it throws error which we are facing.</li>
  </ol>
  
  <p>If this is actually what is happening then what can the fix for this? or else what is causing this error?</p>
  
  <p>If there is any other forum where i can ask this question please share the link in comment section.Thanks in Advance.</p>