This message was deleted.
# rancher-desktop
a
This message was deleted.
r
I would like to be able to reproduce the problem with an example. Is it possible to share a sample (actual commands, yaml files etc) to help me repro please?
f
the source code that has this coverage tests I can't share, but basically I an running a container like this inside the cluster:
Copy code
apiVersion: v1
kind: Pod
spec:
  containers:
    - name: golang-1-20
      image: golang:1.20
      imagePullPolicy: IfNotPresent
      command: [ "cat" ]
      tty: true
      volumeMounts:
      - mountPath: /var/run/docker.sock
        name: socket
      env:
      - name: DOCKER_HOST
        value: "/var/run/docker.sock"
      - name: TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE
        value: "/var/run/docker.sock"
      - name: GOPRIVATE
        value: "<http://github.com/xyz/*|github.com/xyz/*>"
  volumes:
  - name: socket
    hostPath:
      path: /Users/pedro/.docker/docker.sock
Inside the container I run the below commands, some of this tests are using go testcontainers that will try to spin up some containers and there is when I have trouble
Copy code
go mod vendor -v
go test -v -tags=integration -coverprofile=coverage.out -coverpkg=./... ./...
I'll try to find a public example in go so I can share
🙌 1
here it is
Copy code
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  name: testcontainers
spec:
  containers:
  - command: [ "bash", "-c", "git clone <https://github.com/ncomet/testcontainers-go> && cd testcontainers-go && go test -v ./..." ]
    image: golang:1.20
    name: testcontainers
I'm getting closer to something with this try:
Copy code
apiVersion: v1
kind: Pod
metadata:
  name: testcontainers
spec:
  containers:
    - command:
        [
          "bash",
          "-c",
          "git clone <https://github.com/ncomet/testcontainers-go> && cd testcontainers-go && go test -v ./...",
        ]
      image: golang:1.20
      name: testcontainers
      volumeMounts:
        - mountPath: /var/run/docker.sock
          name: socket
      env:
        - name: DOCKER_HOST
          value: unix:///var/run/docker.sock
        - name: TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE
          value: /var/run/docker.sock
  volumes:
    - name: socket
      hostPath:
        path: /run/k3s/containerd/containerd.sock
With this the error is:
Copy code
error: Get "<http://%2Fvar%2Frun%2Fdocker.sock/v1.24/networks>": net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x00\x00\x06\x04\x00\x00\x0 │
│ * Are you trying to connect to a TLS-enabled daemon without TLS?: failed to create container.
yeah, solved with this approach:
Copy code
apiVersion: v1
kind: Pod
metadata:
  name: testcontainers
spec:
  containers:
    - image: docker:20.10.12-dind
      name: dind
      ports:
        - containerPort: 2375
      securityContext:
        privileged: true
      env:
        - name: DOCKER_TLS_CERTDIR
          value: ""
    - command:
        [
          "bash",
          "-c",
          "git clone <https://github.com/ncomet/testcontainers-go> && cd testcontainers-go && go test -v ./...",
        ]
      image: golang:1.20
      name: testcontainers
      env:
        - name: DOCKER_HOST
          value: <tcp://localhost:2375>
not exactly what I wanted but in this case solves, if anyone knows how to use the lima containerd socket from a container running in k8s will be helpful