Pipelines: Custom hostname for docker container


is there any option how can I specify custom hostname for docker container instead of default generated one? Running locally I am able to do this using -h option:


docker run -h custom_host_name image



1 answer

0 vote

Hi Marek,

There is no current functionality to configure the hostname of the Docker container in the Docker run command.

Feel free to open a feature request here: https://bitbucket.org/site/master/issues

Out of curiosity, what's your use-case here? 




Hi Philip,

thanks for info. I got some pre-configured docker image with services bound to a specific host (dbserver). As content of /etc/hosts file is managed by a docker itself, any changes to /etc/hosts during docker build (such as adding a specific host) will be overwritten in the runtime. So the best option is to provide host during container creation with -h dbserver option. Otherwise services will fail due to unresolvable host.

Because I was not able to configure that in such a way in bitbucket I have created my own docker image (based on the original) with custom entrypoint startup script that adds proper host record into /etc/hosts.


if [ `hostname` != "dbserver" ]
echo " dbserver" >> /etc/hosts




Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

706 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot