-
Notifications
You must be signed in to change notification settings - Fork 49
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
docker: Error response from daemon: Conflict. The container name "/mongodb" is already in use by container #24
Comments
I made the error from `MongoDB in GitHub Action disappear by cleaning up the docker images on my actions runner machine:
I'm still getting the same error from the tests. |
If I mess up the connection string, for example:
I get a different error:
|
@akoskm Hey Akos, looks like you're connecting to MongoDB using a Node.js app. Is it the Is your app using the provided MONGO_URI "as is" or do you replace/add some other values (Iike auth credentials)? |
Hey, thanks for the prompt response @marcuspoehls! I'm using Mongoose to connect to MongoDB. MONGO_URI is used "as is". This is how my setup was working with It's really similar to what you have in your test: mongodb-github-action/test/replica-set.js Lines 12 to 19 in 56f4c41
mine goes like this:
where |
Good you found the test using Mongoose. I remember running into issues with the database connection when using Mongoose and replica sets. You already copied the connection details from the test. That's good. Could you please test whether adding the replica set config to the Mongoose object helps? Maybe it gets overridden in the connection string. But I'm not sure. |
Tried this, actually, I wrapped my above connect code such as:
and here's the error I'm getting:
|
@akoskm Looks like your connection string has the wrong port. Can you check whether the |
Oh sorry, in the meantime I updated my yaml config to experiment with different ports:
|
I found in the input of this action the following:
So I tried hardcoding the full URL I see here in my test (compressors cannot be disabled in Mongoose):
I got the following error:
|
Looks like the connection attempt from the logs goes to the default port Just to make sure: you're still using the Mongoose options for URL parser and topology? I remember those being required for replica sets. Mongoose wouldn't connect properly without these Akos, do you work on a public project where I can look at the logs of the GitHub Action? |
I just sent you a link to the build log/yaml file in DM on Twitter. |
Hopefully fixes supercharge#24.
Hello |
@eBsowka I'm still using the
@marcuspoehls do you remember why this wasn't merged into master? Is it the issue with the network not being cleaned up? |
@akoskm @eBsowka Yeah, I remember why I never merged the There are two ways of networking when using docker actions on a self-hosted runners:
While writing this, I think there’s a solution we can build into this MongoDB action: an input that disconnects the container from the network ensuring that your self-hosted runner can clean up correctly (remove container, remove the network). |
@vladkasianenko Hey Vlad, I didn’t look into this issue over the last year. I have to get back digging and reading on container actions. Maybe GitHub changed or improved the way how they work. If you have any knowledge about solving this issue, please share it. I appreciate any progress, hint, and lead 🙂 |
same issue, but I have it in my own server with gitea and act_runner... |
|
Same issue here. It works on CI/CD but fails locally when running with act. Simple setup with single instance:
|
@laurogripa Hey Lauro, looks like CI/CD deletes the containers after processing the pipeline. Locally, act won’t clean up and keep the containers. When running the pipeline a second time, the containers already exist. The container recreation then fails with this issue. One thing coming to my mind: a workaround here could be the explicit acceptance of such cases. For example, we’re extending this MongoDB GitHub Action to contact the Docker daemon and check if the container name that should be used is already present. If a container with the same name already exists, we could accept that and be done. This could be an opt-in setting that is helpful during local development. Would you be interested in contributing this functionality? |
Hey @marcuspoehls Is there a chance to merge the There is a concern when we use the Here is my idea: tests:
run-as: ubuntu-latest
container:
image: php:cli
steps:
uses: supercharge/[email protected]
with:
network: ${{ job.container.network }} This way, we keep the network managed with the GitHub Actions while also ensuring the MongoDB container uses the same network as the workflow job. Due this limitation, in my case, I needed to do the steps performing manually the docker commands, like: run: docker exec ${{ env.container_name }} composer install |
@marcuspoehls thanks for your answer! Oh, yeah, good catch. I thought about this, I was killing the container but forgetting to remove it 🤦 Of course, I'd love to contribute. How do you think this opt-in setting should look, something like |
I'm trying to replace my old mongodb
services
setup withmongodb-github-action
because it gives me an easy way to spin up a replica set.Here's my old setup:
I removed this and put the supercharge action in my build steps:
My problem is that the first test in the "Run unit tests" build step fails to connect to the mongodb instance:
but I think this is caused by an uncaught error that happens much earlier, in MongoDB in GithHub Actions:
For reference, here's how the MongoDB in GithHub Actions command ends:
The text was updated successfully, but these errors were encountered: