error with docker container in bitbucket pipelines
Asked by Zain Khan:

I'm deploying my dockerized Django app using bitbucket pipelines but unfortunately, the pipeline already creates two containers but not the last one the error and my files are attached below.

error:

    ERROR: for db  Cannot create container for service db: authorization denied by plugin pipelines: -v only supports $BITBUCKET_CLONE_DIR and its subdirectoriesEncountered errors while bringing up the project.

docker-compose.yml

    version: "3.8"services:  db:    container_name: db    image: "postgres"    restart: always    volumes:      - postgres-data:/var/lib/postgresql/data/  app:    container_name: app    build:      context: .    restart: always    volumes:      - static-data:/vol/web    depends_on:      - db  proxy:    container_name: proxy    build:      context: ./proxy    restart: always    depends_on:      - app    ports:      - 80:8000    volumes:      - static-data:/vol/staticvolumes:  postgres-data:  static-data:

bitbucket-pipelines.yml

    image: python:3.7.2pipelines:  default:    - step:        services:          - docker        caches:          - docker          - pip        script:          - pip install docker-compose          - docker-compose -f docker-compose-deploy.yml up --build          - pipe: atlassian/aws-code-deploy:0.2.5            variables:              AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION              AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID              AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY              COMMAND: 'upload'              APPLICATION_NAME: $APPLICATION_NAME              ZIP_FILE: 'application.zip'              S3_BUCKET: $S3_BUCKET              VERSION_LABEL: 'my-app-2.0.0'          - pipe: atlassian/aws-code-deploy:0.2.5            variables:              AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION              AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID              AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY              COMMAND: 'deploy'              APPLICATION_NAME: $APPLICATION_NAME              DEPLOYMENT_GROUP: $DEPLOYMENT_GROUP              WAIT: 'true'              S3_BUCKET: $S3_BUCKET              VERSION_LABEL: 'my-app-2.0.0'              IGNORE_APPLICATION_STOP_FAILURES: 'true'              FILE_EXISTS_BEHAVIOR: 'OVERWRITE'definitions:  services:    docker:      memory: 3072


Answers:
author: Theodora Boudale
body: Hi [@Zain Khan](/t5/user/viewprofilepage/user-id/4782915) and welcome to the community!

Based on the error message and the files you included here, I believe the error is caused by the path where you are mounting the volumes. At the moment, we don't support mapping volumes outside of $BITBUCKET_CLONE_DIR:

* <https://support.atlassian.com/bitbucket-cloud/docs/run-docker-commands-in-bitbucket-pipelines/>

> We've had to restrict a few for security reasons, including Docker swarm-related commands, docker run --privileged, docker run --mount, and mapping volumes with a source outside $BITBUCKET_CLONE_DIR.

Volumes will need to be mounted inside $BITBUCKET_CLONE_DIR (/opt/atlassian/bitbucketci/agent/build/.\* or /opt/atlassian/pipelines/agent/build/.\*)

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud