Packer build docker image in Bitbucket Pipeline fails

99 views
Skip to first unread message

Matthew Neirynck

unread,
Nov 16, 2022, 2:49:14 PM11/16/22
to Packer
Hi,
I'm trying to build a docker image using packer in a Bitbucket Pipeline like so:
- step: &build
image: hashicorp/packer
services:
- docker
script:
- export AWS_DEFAULT_REGION=$AWS_REGION
- export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
- packer --version
- packer build -var 'version=$DOCKER_TAG' cicd/packer/packer.pkr.hcl

But this fails with the following error:
==> docker.telsy: Starting docker container...
docker.telsy: Run command: docker run -v /root/.config/packer/tmp3980589757:/packer-files -d -i -t --entrypoint=/bin/sh -- ubuntu:20.04
==> docker.telsy: Error running container: Docker exited with a non-zero exit status.
==> docker.telsy: Stderr: docker: Error response from daemon: authorization denied by plugin pipelines: -v only supports $BITBUCKET_CLONE_DIR and its subdirectories.

Is there a way to specify in Packer not to use the default path to mount into the container, but rather the BITBUCKET_CLONE_DIR?

hannah bekar

unread,
Mar 16, 2023, 12:39:11 AM3/16/23
to Packer
Hi Matthew,

Yes, you can specify the chroot_path parameter in your Packer configuration to set the working directory where Packer will execute the Docker build command.
Here's an updated example Packer configuration file that sets the chroot_path to $BITBUCKET_CLONE_DIR:

Thanks,

Hannah Bekar

https://limaxlock.com


Reply all
Reply to author
Forward
0 new messages