1

I try to transfer my projects CI to GitHub Actions. For integration tests I need to start and access redis container. I am using info from this article. So code looks like this

build-artifacts: name: Build artifacts runs-on: ubuntu-latest services: redis: image: redis:3.2.12 ports: - 6379:6379 

I can access redis using localhost:6379 but I can't access it using redis:6379. The article does not help. What I am doing wrong?

Thank you in advance.

2 Answers 2

2

So I figured out what was the problem. Docker network works only if you run your job inside container. And I had not.

Here is example https://github.com/actions/example-services/blob/989ef69ed164330bee413f11ce9332d76f943af7/.github/workflows/mongodb-service.yml#L19

And a quote:

runs all of the steps inside the specified container rather than on the VM host. Because of this the network configuration changes from host based network to a container network.

Sign up to request clarification or add additional context in comments.

Comments

0

U need to host an external redis database because containers in GitHub Actions are isolated. For other hand u can prepare a docker container with all you need for testing and then u can run the tests inside.

Un can take a look here https://github.com/gonsandia/github-action-deploy Its a custom action where u define the dockerfile and the scripts to runs

2 Comments

I forget to mension I want to run this steps on github server by pushing code. I can not host external redis anywhere.
Then u have to prepare a dockerfile with redis setup and the other stuff u need to run tests. Here github.com/gonsandia/github-action-deploy you can check an example for a custom dockerfile and scripts and how to call a custom action

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.