-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Hi,
we just updated to version 1.0.0, thanks for providing this version!
However, a regression seems to be that pulling from private registries fails locally or in our pipeline if the image is not already present on the host. Because of the nature of private registries, it's not easily possible to provide a full-minimal reproduction
Steps to reproduce
- Add a container with a private registry stored image to test (assume:
xxx.azurecr.io/custom-image:latest) - Validate image is not already present on the local machine:
docker images | grep xxx.azurecr.io/custom-image:latest - Execute the test using this image:
<?php
use PHPUnit\Framework\TestCase;
use Testcontainers\Container\GenericContainer;
use Testcontainers\Container\StartedGenericContainer;
class ContainerTestCase extends TestCase
{
protected StartedGenericContainer $container;
protected function setUp(): void
{
parent::setUp();
$this->container = (new GenericContainer('xxx.azurecr.io/custom-image:latest'))
->start();
}
protected function tearDown(): void
{
$this->container->stop();
}
public function testContainerIsRunning(): void
{
$this->assertNotNull($this->container->getId());
}
}
Fails with:
1) \project\Tests\Integration\models\ContainerTestCase::testContainerIsRunning
Docker\API\Exception\ImageCreateInternalServerErrorException: server error
/project/vendor/beluga-php/docker-php-api/src/Endpoint/ImageCreate.php:132
/project/vendor/beluga-php/docker-php/src/Endpoint/ImageCreate.php:20
/project/vendor/beluga-php/docker-php-api/src/Runtime/Client/EndpointTrait.php:18
/project/vendor/beluga-php/docker-php-api/src/Runtime/Client/Client.php:52
/project/vendor/beluga-php/docker-php/src/Docker.php:71
/project/vendor/testcontainers/testcontainers/src/Container/GenericContainer.php:474
/project/vendor/testcontainers/testcontainers/src/Container/GenericContainer.php:304
/project/tests/Integration/models/ContainerTestCase.php:25Which indicates that the invocation of start() fails. Even when correctly authenticated with the docker registry.
Workaround: Pulling the image works. We have the same issue in github workflows. Docker is authenticated, either via login to the registry locally or adding the login action:
- uses: docker/login-action@v3
with:
registry: xxx.azurecr.io
username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
password: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
- name: 🧪Test
run: |
# Workaround testcontainer can't pull from private cr
docker pull xxx.azurecr.io/custom-image:latest
composer test:integrationjorgsowa
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request