Pipelines: Custom hostname for docker container

marlly December 7, 2016

Hi,

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

Thanks,

Marek

1 answer

0 votes
Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 11, 2016

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? 

Thanks,

Phil

 

marlly December 13, 2016

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.

 

#!/bin/bash
if [ `hostname` != "dbserver" ]
then
echo "127.0.0.1 dbserver" >> /etc/hosts
fi

 

Regards,

Marek

Tomasz Raganowicz March 23, 2018

+1

Marcel Rieger December 3, 2018

Would really love to see this feature implemented also

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events