error with docker container in bitbucket pipelines

Zain Khan March 2, 2022

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 subdirectories
Encountered 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/static

volumes:
  postgres-data:
  static-data:

 

bitbucket-pipelines.yml

image: python:3.7.2

pipelines:
  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

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 4, 2022

Hi @Zain Khan 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:

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events