My host:
» lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial
My docker:
» docker --version
Docker version 17.05.0-ce, build 89658be
What I tried:
1) Setting the hostname in the container: fails becauset the container lacks the right capabilities
root@172:/# hostname something
hostname: you must be root to change the host name
2) Manually editing /etc/hostname
in the container: has no effect after container restart, and has no purpose without restarting.
3) Manually editing the container configuration: it does not work, no idea why.
sudo vi /var/lib/docker/containers/834787a141d73b359814055b5fc0ba3e1cc52effeb6f916e2adece297d600772/config.v2.json
4) Changing the hostname of the container in the host using namespaces tools, as described here: not possible in Ubuntu 16.04.4 LTS
since I have no access to the namespaces tools.
What other options do I have?
Rationale
GitLab seems to pass its current hostname to a GitLab runner for it to clone repositories. In the default network, the container can not be reached by name, only by IP address. That means I need to set the hostname of the gitlab container to the IP address, but I only have the IP address once it is already running. The only solution is thus to:
- Run the container
- Find out its IP address
- Overwrite the hostname with the IP address
- Now gitlab and gitlab runner can talk to each other
The other (clean) option would be to start the containers (gitlab and gitlab-runner) in a custom network, so that they can be reached by real hostname, but currently I have the problem that the containers started by the gitlab runner are not able to reach the required container services spawned by the runner when using custom networks.