Bitbucket Pipelines does not execute the build image's ENTRYPOINT/CMD script
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
When running a build in Bitbucket Pipelines, the build image's ENTRYPOINT or CMD script is not being executed.
Environment
Bitbucket Pipelines on Bitbucket Cloud.
Cause
Once a build is triggered in Bitbucket Pipelines, a build container will be spun up to run the commands defined in the step's script section. The docker run command that is executed in the background in pipelines to start the build container utilizes the --entrypoint flag to override any CMD or ENTRYPOINT previously defined in the build image.
Pipelines needs to overwrite the image's entry point in order to guarantee that it can execute the step commands from your bitbucket-pipelines.yml.
Solution
You can move the script to a file stored in the image, and invoke the script from your step's script on bitbucket-pipelines.yml.
For example, if your image (e.g my/customimage) contains a script in the path /opt/bin/my_script.sh, the script can be invoked directly in bitbucket-pipelines.yml as follows:
- step:
image: my/customimage
script:
- /opt/bin/my_script.sh
If you are encountering issues following this documentation - please raise a support ticket or a community support ticket for further assistance.