Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

ENV in Dockerfile acting differently in pipeline to local Docker

I'm having trouble with backslashes within ENV in a Dockerfile within a pipeline. If I use the same ENV settings in my local Debian environment they are passed through without issue. Image used is debian:buster-slim


For example this gets corrupted in the pipeline:
ENV SMTP_PASSWORD='aaaaaaaA\"n111111'

It appears in the container as aaaaaaaA"n

This one just refuses to show up at all in the container but no error is given:
ENV SMTP_PASSWORD='aaaaaaaA\\"n111111'

If I build a docker container locally both of the above examples passthrough as is. Does anyone know how to fix this?

1 answer

0 votes

Hi Rob and welcome to the community.

Could you please let me know where you see this corrupted value of the variable?
- Is it in the output of the 'docker build' command, in the Pipelines build where you build this Dockerfile?
- Is it in the image layers of the Docker repository in the registry you use, after you push the image?
- Or do you use this image you build from the Dockerfile as a build container for Pipelines in another Bitbucket repo, and you see the corrupted value when you echo the variable there?

I haven't been able to reproduce this issue using variables with the same values you mentioned, so it would be useful to have some additional info.

If it's the latter case, can you please check if there is a repository or workspace variable with the same name (SMTP_PASSWORD) defined in the repository that uses this image (or the workspace that owns this repo)? If you have a repository or workspace variable with the same name, I believe that it will overwrite the variable of the container. If a deployment step in Pipelines is using that image as a build container, I also suggest checking the deployment variables as well.

If you're still having issues, it would be useful to know
(a) where and how you see the corrupted value
(b) what value do you see in the output of the 'docker build' command in the Pipelines build where you build this image

Kind regards,

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events