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

Podman with Docker-compose not working #5351

Open
ssrikanthc opened this issue May 6, 2022 · 6 comments
Open

Podman with Docker-compose not working #5351

ssrikanthc opened this issue May 6, 2022 · 6 comments

Comments

@ssrikanthc
Copy link

Trying to get testcontainers work with Podman and Docker-compose in Fedora 35 OS to run tests on a custom Kafka cluster. Tried the following approaches but all of them are failing:

1st Approach:
@container
private static final DockerComposeContainer kafka = new DockerComposeContainer(
new File("src/test/resources/compose-test.yml")).withOptions("--compatibility")
.withExposedService(KAFKA_SERVICE, KAFKA_PORT,
Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(360)))
.withLocalCompose(true);

This approach throws the below error "Link is not supported"
image

Seemingly related to the deprecated addLink method below:
image

2nd Approach:
@container
private static final DockerComposeContainer kafka = new DockerComposeContainer(
new File("src/test/resources/compose-test.yml")).withOptions("--compatibility")
.waitingFor(KAFKA_SERVICE, Wait.defaultWaitStrategy().withStartupTimeout(Duration.ofSeconds(360)))
.withLocalCompose(true);

This approach simply throws a null pointer error:
image

3rd Approach:
@container
private static final DockerComposeContainer kafka = new DockerComposeContainer(
new File("src/test/resources/compose-test.yml")).withOptions("--compatibility")
.waitingFor(KAFKA_SERVICE, Wait.defaultWaitStrategy().withStartupTimeout(Duration.ofSeconds(360)));

This approach throws the below error:
image
image
But, the file in the error has Read/Write/Execute permissions for all users.

@kiview
Copy link
Member

kiview commented May 8, 2022

Would you expect that Podman works together with Docker Compose outside of Testcontainers? Can you give a CLI example of how Podman can work with Docker Compose?

@ssrikanthc
Copy link
Author

@kiview, thanks for your response. I am using the below CLI commands to make Podman work with Docker-compose
sudo systemctl enable podman.socket
sudo systemctl start podman.socket
sudo systemctl status podman.socket

##or##

systemctl --user enable podman.socket
systemctl --user start podman.socket
systemctl --user status podman.socket
export DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock

Reference:
https://fedoramagazine.org/use-docker-compose-with-podman-to-orchestrate-containers-on-fedora/
https://www.redhat.com/sysadmin/podman-docker-compose

@bjconlan
Copy link

bjconlan commented Dec 5, 2022

I'm seeing better behaviour than this on podman 4.3.1 (rootless).

But im seeing issue surrounding socat initialisation:

11:38:09.386 [main] INFO  🐳 [docker-compose] - Docker Compose has finished running
11:38:09.530 [main] INFO  🐳 [alpine/socat:1.7.4.3-r0] - Creating container for image: alpine/socat:1.7.4.3-r0
11:38:09.741 [main] ERROR 🐳 [alpine/socat:1.7.4.3-r0] - Could not start container
org.testcontainers.containers.ContainerLaunchException: Aborting attempt to link to container 2t1bdw4yyjmb_formio.mock_1 as it is not running

It looks like there is a similar reported side effect issue for this problem. But i suspect it also might be due to the slirp networking functionality.

Further investigation looks like this is actually a failure in starting the socat container due to using the 'link' functionality not matching names in GenericContainer::findLinksFromThisContainer due to snake vs kebab naming

There also looks like some other issues here with podman around naming (in regards to linking which is moot since podman linking fails independent of correctly named containers/links
image

Looks like this might stem from go vs python docker-compose implementations

This naming convention difference appears to be a difference between Docker Compose versions v1 (Python) and v2 (Go). The latest docker/compose repo that is packaged with Docker Desktop is the golang version in the docker/compose v2 branch. Looking at the source code here in this branch:

so perhaps a compat flag is required to allow kebab naming in https://github.com/testcontainers/testcontainers-java/blob/main/core/src/main/java/org/testcontainers/containers/DockerComposeContainer.java#L430)

@jfrantzius
Copy link

I do have docker-compose from CLI working with Podman Desktop on Mac, so that generally does work.

Any attempt at running Testcontainer's ComposeContainer, though, (with or without withLocalCompose(true) or DockerComposeContainer eventually result in

15:35:57.082 [main] ERROR tc.alpine/socat:1.7.4.3-r0 - Could not start container
com.github.dockerjava.api.exception.BadRequestException: Status 400: {"cause":"link is not supported","message":"bad parameter: link is not supported","response":400}

This seems to be because Testcontainer makes use of Legacy container links, which is deprecated also in Testcontainer's own API (as @ssrikanthc pointed out). With Testcontainers 1.19.3, this seems to be happening in org.testcontainers.containers.ComposeDelegate.withExposedService(String, int, WaitStrategy), line 315, which calls ambassadorContainer.addLink()

The workaround seems to be not to use (ComposeContainer|DockerComposeContainer).withExposedServices(), as that is what is triggering the call to ambassadorContainer.addLink().

There is #465, which lists as "Modify Docker Compose support; can we remove use of the ambassador container now?" as a completed task?

@chenlin2001
Copy link

Hi, Is there an update on this issue? We are facing similar problems after moving from docker desktop to podman.
Using DockerComposeContainer with testcontainers version 1.17.6 we get the following error:
[10] Failed to execute script docker-compose Traceback (most recent call last): File "urllib3/connectionpool.py", line 677, in urlopen File "urllib3/connectionpool.py", line 392, in _make_request File "http/client.py", line 1277, in request File "http/client.py", line 1323, in _send_request File "http/client.py", line 1272, in endheaders File "http/client.py", line 1032, in _send_output File "http/client.py", line 972, in send File "docker/transport/unixconn.py", line 43, in connect PermissionError: [Errno 13] Permission denied
Upgrading to version 1.19.0 using DockerComposecontainer fails on out of heap memory as described in: #7239
Tried using ComposeContainer with version 1.19.0 and localmode in order to avoid the heap issues and facing the issue of Link is not supported.

Podman compose without testcontainers work on that docker-compose.yaml

@jfrantzius
Copy link

Hi @chenlin2001 , I'm not sure I had the same error, but concerning Permission denied errors you might want to have a look at https://gist.github.com/jfrantzius/0996e224cbe81d885553ece6f8abf99a#status-500-lsetxattr-varrundockersock-operation-not-permitted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants