What server URL should one provide for TeamCity agent in Docker? - linux

The problem. I am trying to create a TeamCity infrastructure (a server and an agent) on Ubuntu Linux 16.04.1 LTS using Docker. I have run a Docker container with jetbrains/teamcity-server image as described on this page. It is possible to access the TeamCity server via web browser using the IP address of the server and port 8111.
Now I try to run a Docker container with an agent as described on this page. It is written: Note that "localhost" will not generally not work as that will refer to the "localhost" inside the container. Well, when I supply "http://localhost:8111", or "http://127.0.0.1:8111", or "http://my_server_ip:8111" to the running script for the agent container I finally get 1) "WARN - buildServer.AGENT.registration - Error registering on the server via URL http://localhost:8111 (sic! always localhost). Will continue repeating connection attempts.", or 2) "WARN - buildServer.AGENT.registration - Error while asking server for the communication protocols via URL http://localhost:8111/app/agents/protocols."
Also I have tried to reveal the IP address of the Docker container running the server and supply it for the agent running script. But the result was the same.
Question. What server URL I should provide? Are there any implicit steps in the TeamCity configuration with Docker which I miss?

You can use the --link parameter to link containers:
Start your jetbrains/teamcity-server and use --name teamcity-server to give it a descriptive name
Start the agent container and use --link teamcity-server to enable connectivity to the teamcity-server container
Inside of your agent container you can now use teamcity-server as the hostname to connect to the teamcity-server container
Please also check out Docker container networking which superseded the --link feature.

Related

configure proxy for container

I have a VM for linux without accessing to the internet, instead I can use proxy. I have docker on the machine and I need to have access to the specific URLs (Which are already added to the proxy). I have the proxy URL. I configured it for the docker which is suggested in both documents:
https://docs.docker.com/config/daemon/systemd/
https://docs.docker.com/network/proxy/
My problem is the proxy works for the docker daemon but it is not passed to the container. The container is not able to use the proxy. However, I can see the $http_proxy and $https_proxy with this 'systemctl show docker --property Environment' command.
Also, before running the container I set $http_proxy and $https_proxy (export ... ). Then run docker exec <cadd_container_id> echo $http_proxy, It printed the proxy but I do not see the proxy in docker env.

How to Access Postgres Service from Child Docker Container in Gitlab-CI? How do I access IP address of postgres service or gitlab shared runner?

I have setup a gitlab-ci build with the architecture illustrated below.
(source: gitlab.com)
.
The listener container is unable to communicate with the postgres container using the hostname, ‘postgres’. The hostname is unrecognised. How can the listener container communicate with the postgres database instance?
The documentation recommends configuring a postgres instance as a service in .gitlab-cy.yml. CI jobs defined in .gitlab-ci.yml, are able to connect to the postgres instance via the service name, 'postgres'.
The tusd, minio and listener containers are spawned within a docker-compose process, triggered inside the pytest CI job. The listener container writes information back to the postgres database.
Subsequently, I thought about using the IP address of the postgres service in place of the hostname. From within the pytest CI build job I have tried to determine the IP address of the postgres database using the following bash command sequence:
export DB_IP="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' postgres)"
echo "DB IP ADDRESS IS $DB_IP"
However, postgres is not recognised as a container.
How do I determine the IP address of the postgres service? Alternatively can I use the IP address of the shared runner? How do I determine this?
Does anybody have any ideas?
Update 11/1/2019
Resolved by moving all services into docker-compose file so that they can communicate with each other. This includes the postgres container etc…After some refactoring in test environment initialisation, tests are now invoked via docker-compose run command.
Now able to successfully run tests using gitlab-shared runner…

Connecting to Azure Container Services from Windows 8.1 Docker

I've been following this tutorial to set up an Azure container service. I can successfully connect to the master load balancer via putty. However, I'm having trouble connecting to the Azure container via docker.
~ docker -H 192.168.33.400:2375 ps -a
error during connect: Get https://192.168.33.400:2375/v1.30/containers/json?all=1: dial tcp 192.168.33.400:2375: connectex: No connection could be made because the target machine actively refused it.
I've also tried
~ docker -H 127.0.0.1:2375 ps -a
This causes the docker terminal to hang forever.
192.168.33.400 is my docker machine ip.
My guess is I haven't setup the tunneling correctly and this has something to do with how docker runs on Windows 8.1 (via VM).
I've created an environment variable called DOCKER_HOST with a value of 2375. I've also tried changing the value to 192.168.33.400:2375.
I've tried the following tunnels in putty,
1. L2375 192.168.33.400:2375
2. L2375 127.0.0.1:2375
3. L22375 192.168.33.400:2375
4. L22375 127.0.0.1:2375 (as shown in the video)
Does anyone have any ideas/suggestions?
Here are some screenshots of the commands I ran:
We can follow this steps to setup tunnel:
1.Add Azure container service FQDN to Putty:
2.Add private key(PPK) to Putty:
3.Add tunnel information to Putty:
Then we can use cmd to test it:

Gitlab registry...unable to login not running?

Followed the gitlab-registry guide to get it running (and enabled to project)
I know the HTTPS works fine (TLS via letsencrypt) because when i login to my gitlab, it successfully redirects to https.
when attempting to login to docker however:
docker login (my domain)
i am getting:
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
netstat -tulpn shows that registry running on 4567
but completely unable to connect to it
You need to have docker installed on the machine you are running docker login from. And if it's installed, you need to be root or in the docker group.

connecting to services on docker host from docker container

Apologies for asking two unrelated questions.
what is the best way of accessing the host machine of the docker container (i.e. I am trying to access a kafka instance running on the host, from my docker container so that I can publish some messages)
when I run docker run ..... on an image which I've modified that may have an issue/syntax error, it will naturally not start - is there a log file anywhere that I would be able to take a look at to debug the issue. (this question is somewhat related to the 1st question, since I did what was suggested on another post, but the image is still not starting)
This is an ongoing discussion on what to use and what not, I don't really know what is best. Using the docker run --net="host" is pretty easy but can be dangerous. See From inside of a Docker container, how do I connect to the localhost of the machine?.
Use docker logs containerid or lookup the raw data in /var/lib/docker/containers/containerid/ for Ubuntu.
You should have no problem connecting to the host using the local lan interface ip address. Suppose you have a host with ip 192.168.0.1:
docker run --rm -ti ubuntu bash
ping 192.168.0.1
should give you a response.
You can use docker logs to see the standard output of your container.

Resources