René's URL Explorer Experiment


Title: Bug: `ConnectionRefusedError: [Errno 111] Connection refused` via docker-compose on Github Actions · Issue #558 · testcontainers/testcontainers-python · GitHub

Open Graph Title: Bug: `ConnectionRefusedError: [Errno 111] Connection refused` via docker-compose on Github Actions · Issue #558 · testcontainers/testcontainers-python

X Title: Bug: `ConnectionRefusedError: [Errno 111] Connection refused` via docker-compose on Github Actions · Issue #558 · testcontainers/testcontainers-python

Description: Describe the bug This seems potentially related to #517 and #475 TLDR; I am able to connect to the PG testcontainer from within docker running locally on a macbook, but running in github actions I get a connection error. I'm experiencing...

Open Graph Description: Describe the bug This seems potentially related to #517 and #475 TLDR; I am able to connect to the PG testcontainer from within docker running locally on a macbook, but running in github actions I ...

X Description: Describe the bug This seems potentially related to #517 and #475 TLDR; I am able to connect to the PG testcontainer from within docker running locally on a macbook, but running in github actions I ...

Opengraph URL: https://github.com/testcontainers/testcontainers-python/issues/558

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug: `ConnectionRefusedError: [Errno 111] Connection refused` via docker-compose on Github Actions","articleBody":"**Describe the bug**\r\n\r\nThis seems potentially related to https://github.com/testcontainers/testcontainers-python/issues/517 and https://github.com/testcontainers/testcontainers-python/issues/475\r\n\r\nTLDR; I am able to connect to the PG testcontainer from within docker running locally on a macbook, but running in github actions I get a connection error.\r\n\r\nI'm experiencing a `ConnectionRefusedError: [Errno 111] Connection refused` error when attempting connecting to the postgres testcontainer when running my tests via docker-compose on a Github action. However I am able to run the tests within docker-compose locally on my macbook.\r\n\r\nI followed the instructions here for running `testcontainers` from within docker\r\n\r\nhttps://golang.testcontainers.org/system_requirements/ci/gitlab_ci/#example-using-docker-socket\r\n\r\nThis is the error I see in Github Actions\r\n\r\n```python\r\n        for _ in range(50):\r\n            try:\r\n                Reaper._socket = socket()\r\n\u003e               Reaper._socket.connect((container_host, container_port))\r\nE               ConnectionRefusedError: [Errno 111] Connection refused\r\n/venv/lib/python3.11/site-packages/testcontainers/core/container.py:228: ConnectionRefusedError\r\n```\r\n\r\nBelow is the full stack trace \r\n\r\n\u003cdetails\u003e\r\n\r\n\u003csummary\u003eGithub Actions Stack Trace\u003c/summary\u003e\r\n\r\n```\r\n________________________ ERROR at setup of test_search _________________________\r\n    @pytest.fixture(scope=\"session\")\r\n    def db_url():\r\n        print(\"YO\")\r\n        print(set([a[4][0] for a in socket.getaddrinfo(socket.gethostname(), None)]))\r\n\u003e       with PostgresContainer(\"postgres:13.1\") as postgres:\r\ntests/conftest.py:21: \r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r\n/venv/lib/python3.11/site-packages/testcontainers/core/container.py:111: in __enter__\r\n    return self.start()\r\n/venv/lib/python3.11/site-packages/testcontainers/core/generic.py:70: in start\r\n    super().start()\r\n/venv/lib/python3.11/site-packages/testcontainers/core/container.py:87: in start\r\n    Reaper.get_instance()\r\n/venv/lib/python3.11/site-packages/testcontainers/core/container.py:188: in get_instance\r\n    Reaper._instance = Reaper._create_instance()\r\n/venv/lib/python3.11/site-packages/testcontainers/core/container.py:242: in _create_instance\r\n    raise last_connection_exception\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r\ncls = \u003cclass 'testcontainers.core.container.Reaper'\u003e\r\n    @classmethod\r\n    def _create_instance(cls) -\u003e \"Reaper\":\r\n        logger.debug(f\"Creating new Reaper for session: {SESSION_ID}\")\r\n    \r\n        Reaper._container = (\r\n            DockerContainer(c.ryuk_image)\r\n            .with_name(f\"testcontainers-ryuk-{SESSION_ID}\")\r\n            .with_exposed_ports(8080)\r\n            .with_volume_mapping(c.ryuk_docker_socket, \"/var/run/docker.sock\", \"rw\")\r\n            .with_kwargs(privileged=c.ryuk_privileged, auto_remove=True)\r\n            .with_env(\"RYUK_RECONNECTION_TIMEOUT\", c.ryuk_reconnection_timeout)\r\n            .start()\r\n        )\r\n        wait_for_logs(Reaper._container, r\".* Started!\")\r\n    \r\n        container_host = Reaper._container.get_container_host_ip()\r\n        container_port = int(Reaper._container.get_exposed_port(8080))\r\n    \r\n        last_connection_exception: Optional[Exception] = None\r\n        for _ in range(50):\r\n            try:\r\n                Reaper._socket = socket()\r\n\u003e               Reaper._socket.connect((container_host, container_port))\r\nE               ConnectionRefusedError: [Errno 111] Connection refused\r\n/venv/lib/python3.11/site-packages/testcontainers/core/container.py:228: ConnectionRefusedError\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\nThe following is my test setup:\r\n\r\n`conftest.py`\r\n```python\r\n@pytest.fixture(scope=\"session\")\r\ndef db_url():\r\n    with PostgresContainer(\"postgres:13.1\") as postgres:\r\n        url = postgres.get_connection_url()\r\n        yield url\r\n```\r\n\r\nThe following is the docker command I'm using to run the tests via `make test`. I've also tried multiple variations of the volume mapping to with no luck. \r\n\r\n```make\r\ntest:\r\n\tdocker-compose run --rm \\\r\n\t -v ${PWD}:${PWD} -w ${PWD}/server \\\r\n\t -v /var/run/docker.sock:/var/run/docker.sock \\\r\n\t --entrypoint \"\" server poetry run pytest -vv\r\n```\r\n\r\nwhere the `server` image is in my `docker-compose.yml` is \r\n\r\n```yml\r\n  server:\r\n    container_name: svs_server\r\n    platform: linux/amd64\r\n    build: ./server\r\n    image: \"svs_server:local\"\r\n    ports:\r\n      - \"8000:8000\"\r\n    volumes:\r\n      - \"./server:/app\"\r\n      - \"./db:/app/db\"\r\n      - \"./tmp:/tmp\"\r\n    env_file:\r\n      - .env\r\n      - .env.secret\r\n ```\r\n\r\n\r\nI am able to successfully get the testcontainers/docker-compose setup running locally on my macbook (docker desktop) with the following, notice the only difference is the additional host override and lack of mapped volumes.\r\n\r\n```make\r\ntest-local:\r\n\tdocker-compose run --rm \\\r\n\t -v /var/run/docker.sock:/var/run/docker.sock \\\r\n\t -e TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal \\\r\n\t --entrypoint \"\" server poetry run pytest -vv\r\n```\r\n\r\n\r\n**Runtime environment**\r\n\r\nI also tried finding more info about the network via running the following within the action.\r\n\r\n`print(set([a[4][0] for a in socket.getaddrinfo(socket.gethostname(), None)]))`\r\n\r\nThis returns an IP such as `{'172.18.0.2'}` but it is slightly different each time.\r\n\r\n- Running within Github Actions\r\n- Python 3.11 via the `FROM python:3.11-slim-buster` image\r\n- docker info\r\n```\r\nClient: Docker Engine - Community Version: 24.0.9 Context: default Debug Mode: false Plugins: buildx: Docker Buildx (Docker Inc.) Version: v0.14.0 Path: /usr/libexec/docker/cli-plugins/docker-buildx compose: Docker Compose (Docker Inc.) Version: v2.23.3 Path: /usr/libexec/docker/cli-plugins/docker-compose Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 14 Server Version: 24.0.9 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Using metacopy: false Native Overlay Diff: false userxattr: false Logging Driver: json-file Cgroup Driver: cgroupfs Cgroup Version: 2 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: runc io.containerd.runc.v2 Default Runtime: runc Init Binary: docker-init containerd version: e377cd56a71523140ca6ae87e30244719194a521 runc version: v1.1.12-0-g51d5e94 init version: de40ad0 Security Options: apparmor seccomp Profile: builtin cgroupns Kernel Version: 6.5.0-1018-azure Operating System: Ubuntu 22.04.4 LTS OSType: linux Architecture: x86_64 CPUs: 2 Total Memory: 7.744GiB Name: fv-az822-516 ID: 584d62f5-11d9-4074-87e4-acacf60905a6 Docker Root Dir: /var/lib/docker Debug Mode: false Username: githubactions Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false\r\n```\r\n- docker-compose version\r\n`docker-compose version 1.29.2, build 5becea4c`\r\n\r\n- `uname -a`\r\n`Linux fv-az822-516 6.5.0-1018-azure #19~22.04.2-Ubuntu SMP Thu Mar 21 16:45:46 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux`\r\n\r\n---\r\n\r\nLet me know if there's any other additional debugging info I can provide that would help, thanks!!","author":{"url":"https://github.com/stv8","@type":"Person","name":"stv8"},"datePublished":"2024-04-28T17:54:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/558/testcontainers-python/issues/558"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:05f721ce-5016-76f5-65dd-fafa4184508c
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC244:39FF2E:27DFEF:366A48:6A55392B
html-safe-nonced32fb41fc224cf7dae97157b388e4c8ee93f9b925c3402c13c21137f193276a3
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMjQ0OjM5RkYyRToyN0RGRUY6MzY2QTQ4OjZBNTUzOTJCIiwidmlzaXRvcl9pZCI6IjkzNDgxMzk5MTgzNDA0MDYxOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacfc46fa5221eeec84e0578e3925d4e4946907f7ccede448be4ac9ddcd80fd3fe4
hovercard-subject-tagissue:2267711565
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/testcontainers/testcontainers-python/558/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4c2b065628004ca289f528c60356b10c39d9e72f6a04d2b157417c5a0a8d53a1/testcontainers/testcontainers-python/issues/558
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4c2b065628004ca289f528c60356b10c39d9e72f6a04d2b157417c5a0a8d53a1/testcontainers/testcontainers-python/issues/558
og:image:altDescribe the bug This seems potentially related to #517 and #475 TLDR; I am able to connect to the PG testcontainer from within docker running locally on a macbook, but running in github actions I ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamestv8
hostnamegithub.com
expected-hostnamegithub.com
Nonefbd8fce4d63ac394c5405faa20aa50d5c9e56b979ac43ee1b26f8e7c47c4cd89
turbo-cache-controlno-preview
go-importgithub.com/testcontainers/testcontainers-python git https://github.com/testcontainers/testcontainers-python.git
octolytics-dimension-user_id13393021
octolytics-dimension-user_logintestcontainers
octolytics-dimension-repository_id85802819
octolytics-dimension-repository_nwotestcontainers/testcontainers-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id85802819
octolytics-dimension-repository_network_root_nwotestcontainers/testcontainers-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release811f50b757204c6a1b4da0ea780075b3e1cc9e57
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/testcontainers/testcontainers-python/issues/558#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftestcontainers%2Ftestcontainers-python%2Fissues%2F558
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftestcontainers%2Ftestcontainers-python%2Fissues%2F558
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=testcontainers%2Ftestcontainers-python
Reloadhttps://github.com/testcontainers/testcontainers-python/issues/558
Reloadhttps://github.com/testcontainers/testcontainers-python/issues/558
Reloadhttps://github.com/testcontainers/testcontainers-python/issues/558
Please reload this pagehttps://github.com/testcontainers/testcontainers-python/issues/558
testcontainers https://github.com/testcontainers
testcontainers-pythonhttps://github.com/testcontainers/testcontainers-python
Notifications https://github.com/login?return_to=%2Ftestcontainers%2Ftestcontainers-python
Fork 375 https://github.com/login?return_to=%2Ftestcontainers%2Ftestcontainers-python
Star 2.3k https://github.com/login?return_to=%2Ftestcontainers%2Ftestcontainers-python
Code https://github.com/testcontainers/testcontainers-python
Issues 131 https://github.com/testcontainers/testcontainers-python/issues
Pull requests 35 https://github.com/testcontainers/testcontainers-python/pulls
Discussions https://github.com/testcontainers/testcontainers-python/discussions
Actions https://github.com/testcontainers/testcontainers-python/actions
Security and quality 0 https://github.com/testcontainers/testcontainers-python/security
Insights https://github.com/testcontainers/testcontainers-python/pulse
Code https://github.com/testcontainers/testcontainers-python
Issues https://github.com/testcontainers/testcontainers-python/issues
Pull requests https://github.com/testcontainers/testcontainers-python/pulls
Discussions https://github.com/testcontainers/testcontainers-python/discussions
Actions https://github.com/testcontainers/testcontainers-python/actions
Security and quality https://github.com/testcontainers/testcontainers-python/security
Insights https://github.com/testcontainers/testcontainers-python/pulse
Bug: ConnectionRefusedError: [Errno 111] Connection refused via docker-compose on Github Actionshttps://github.com/testcontainers/testcontainers-python/issues/558#top
https://github.com/stv8
stv8https://github.com/stv8
on Apr 28, 2024https://github.com/testcontainers/testcontainers-python/issues/558#issue-2267711565
#517https://github.com/testcontainers/testcontainers-python/issues/517
#475https://github.com/testcontainers/testcontainers-python/issues/475
https://golang.testcontainers.org/system_requirements/ci/gitlab_ci/#example-using-docker-sockethttps://golang.testcontainers.org/system_requirements/ci/gitlab_ci/#example-using-docker-socket
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.