Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs for using Gitlab CI with Docker wormhole executor #4770

Merged
merged 5 commits into from
May 18, 2022

Conversation

JurrianFahner
Copy link
Contributor

I had problems to get my configuration working for testcontainers in combination with gitlab. On my machine everything did run completely fine. But in Gitlab CI I got problems with Ryuk and also my mongo container couldn't be found. This was due to a wrong resolved ip address.
I found out when setting the TESTCONTAINERS_HOST_OVERRIDE to host.docker.internal that it helped me a lot to solve these issues (since testcontainers exposes the ports on the host).

Since my configuration is quite generic, I thought it would be nice to include it in the docs so other people could also benefit.

I had problems to get my configuration working for testcontainers in combination with gitlab. On my machine everything did run completely fine. But in Gitlab CI I got problems with Ryuk and also my mongo container couldn't be found. This was due to a wrong resolved ip address. 
I found out when setting  the `TESTCONTAINERS_HOST_OVERRIDE` to `host.docker.internal` that it helped me a lot to solve these issues (since testcontainers exposes the ports on the host). 

Since my configuration is quite generic, I thought it would be nice to include it in the docs so other people could also benefit.
@kiview
Copy link
Member

kiview commented Dec 8, 2021

Hi @JurrianFahner,
thanks for raising the PR and letting us know. I think we should not duplicate bigger parts of the GitLab docs and the runner config in our docs, since there is too much risk of things changing on the GitLab side and our docs becoming incorrect.

Therefore, I think it is best to only document the need for

  variables:
    TESTCONTAINERS_HOST_OVERRIDE: "host.docker.internal"

in case of using a Docker-Socket-Mounting setup.

Besides this, I wonder if something has changed on the GitLab-CI side since I used to run exactly this setup some years ago without the need of setting TESTCONTAINERS_HOST_OVERRIDE. Sadly it's not so convenient to try this out by myself without setting up my own GitLab-CI runner.

@JurrianFahner
Copy link
Contributor Author

@kiview It worked for me till I upgraded from 1.15.1 to 1.16.2. The problem is that testcontainers somehow got the ip address wrong.

You have definitely a point by make the contribution smaller and describe it as a known issue, which might be fixed by only describe how it can be fixed with TESTCONTAINERS_HOST_OVERRIDE env var.

I'll rewrite my contribution somewhere this week.

Thanks for your fast response!

@kiview
Copy link
Member

kiview commented Dec 9, 2021

Thanks for the clarification. Do you have a way to quickly check if the current DinD based GitLab-CI docs are also broken after 1.16.2?
https://www.testcontainers.org/supported_docker_environment/continuous_integration/gitlab_ci/

@JurrianFahner JurrianFahner changed the title Add another gitlab configuration to the docs How to troubleshoot your docker build if the host ip can't be determined Dec 9, 2021
@JurrianFahner
Copy link
Contributor Author

No, I don't have a way to check quickly DinD configuration. I suspect that DinD is also broken. I also don't think the docker socket is the problem, whether you would use a tcp socket or a file socket that doesn't matter (from my point of view).

In my case the docker container is created (via the /var/run/docker.sock), but the testcontainer library can't find my host ip. So the created docker container can't be reached by the test.

@JurrianFahner
Copy link
Contributor Author

JurrianFahner commented Dec 9, 2021

@kiview I have looked in the gitlab docs for a good example of a gitlab runner. But I couldn't find it. Can we leave it here? I have removed the parts that are empty.

Another approach would be to add examples on gitlab to demonstrate how to perform testcontainer tests on gitlab within a docker container. I have already created a gitlab group for it: https://gitlab.com/testcontainers-examples.
I don't mind to transfer the ownership.

Copy link
Member

@kiview kiview left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested some changes to the wording. Afterwards, it is good to go from my side, thanks 👍

Regarding your proposal about example GitLab projects, this sounds like a very good idea. What I would imagine (at least for now) is a community maintained project, that shows how the different executors have to be configured to work with Testcontainers. Ideally this would also help us in catching regressions with regards to GitLab CI.

@JurrianFahner
Copy link
Contributor Author

@kiview I'm convinced that I did apply your feedback. Can you approve?

@JurrianFahner
Copy link
Contributor Author

@kiview Can you give it a second look? Your suggestions have been applied. But somehow github doesn't pick it up....
What do I need to do in order to fix it?

@bsideup bsideup added this to the next milestone May 17, 2022
@kiview kiview changed the title How to troubleshoot your docker build if the host ip can't be determined Add docs for using Gitlab CI with Docker wormhole executor May 18, 2022
@kiview kiview merged commit b8d75b1 into testcontainers:master May 18, 2022
@kiview
Copy link
Member

kiview commented May 18, 2022

@JurrianFahner Sorry for having this overlooked, I just merged it. Thanks a lot for this contribution 🙌

@JurrianFahner JurrianFahner deleted the patch-1 branch May 23, 2022 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants