containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
23.33k stars 2.38k forks source link

Running podman in podman results into an error to get to DNS server #23009

Closed flixman closed 3 months ago

flixman commented 3 months ago

Issue Description

My gitea runner is using podman, and I want to use podman inside (to build and test my containers) as well. To this end, I am building the image used by the runner as:

FROM quay.io/podman/stable

RUN dnf install -y git nodejs && \
    dnf clean all && \
    rm -rf /var/cache/yum

ADD --chmod=755 https://github.com/docker/compose/releases/download/v2.27.1/docker-compose-linux-x86_64 /bin/docker-compose

USER podman
WORKDIR /home/podman

Then, I am running a task on the runner as:

jobs:
    build:
        runs-on: podman
        container:
            volumes:
                - /mnt/act_runner/buildah-cache:/var/tmp/buildah-cache-1000
        steps:
            - name: Checkout
              uses: actions/checkout@v4

            - name: Login to registry
              run: |
                  podman login -u myuser -p ${{ secrets.RUNNER_LDAP_PASSWORD }} myregistry.org

            - name: Build
              run: |
                  hash=${{ env.GITHUB_SHA }}
                  podman build -t app/app:acc --build-arg GIT_COMMIT=${hash::8} --build-arg GIT_REF="${{ github.ref_name }}" -f docker/app/Dockerfile .

            - name: Test Unit/integration
              env:
                  DOCKER_HOST: unix:/run/podman/podman.sock
              run: |
                  echo "Building CI image"
                  podman build -t app/app:test -f docker/ci/Dockerfile .

                  echo "Running tests"
                  podman system service --time=0 &

                  podman info
                  docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.test.yml up app
                  docker-compose down -v

            - name: Push image to myregistry.org
              run: |
                  podman push app/app:acc docker://myregistry.org/app/app:acc

the podman commands run as expected, but for the docker-compose (which is pointing to podman socket, I have the same setup running locally for other containers), I am getting this error:

error during connect: Get "http://unix:2375/run/podman/podman.sock/v1.45/containers/json?all=1&filters=%7B%22label%22%3A%7B%22com.docker.compose.config-hash%22%3Atrue%2C%22com.docker.compose.project%app%22%3Atrue%7D%7D": dial tcp: lookup unix on 10.89.0.1:53: no such host

Steps to reproduce the issue

Steps to reproduce the issue

  1. run the docker-compose command while inside the podman container run by Gitea

Describe the results you received

error during connect: Get "http://unix:2375/run/podman/podman.sock/v1.45/containers/json?all=1&filters=%7B%22label%22%3A%7B%22com.docker.compose.config-hash%22%3Atrue%2C%22com.docker.compose.project%app%22%3Atrue%7D%7D": dial tcp: lookup unix on 10.89.0.1:53: no such host

Describe the results you expected

The containers start as expected and my tests get run.

podman info output

host:
  arch: amd64
  buildahVersion: 1.35.4
  cgroupControllers:
  - cpu
  - memory
  - pids
  cgroupManager: cgroupfs
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.10-1.fc40.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.10, commit: '
  cpuUtilization:
    idlePercent: 97.99
    systemPercent: 0.74
    userPercent: 1.27
  cpus: 4
  databaseBackend: sqlite
  distribution:
    distribution: fedora
    variant: container
    version: "40"
  eventLogger: file
  freeLocks: 2048
  hostname: 55a329607888
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 1
      size: 999
    - container_id: 1000
      host_id: 1001
      size: 64535
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 1
      size: 999
    - container_id: 1000
      host_id: 1001
      size: 64535
  kernel: 6.1.0-21-amd64
  linkmode: dynamic
  logDriver: k8s-file
  memFree: 1440104448
  memTotal: 7968169984
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.10.0-1.fc40.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.10.0
    package: netavark-1.10.3-3.fc40.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.10.3
  ociRuntime:
    name: crun
    package: crun-1.15-1.fc40.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.15
      commit: e6eacaf4034e84185fd8780ac9262bbf57082278
      rundir: /tmp/storage-run-1000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20240510.g7288448-1.fc40.x86_64
    version: |
      pasta 0^20240510.g7288448-1.fc40.x86_64-pasta
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: true
    path: /tmp/storage-run-1000/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 1576267776
  swapTotal: 1999630336
  uptime: 789h 36m 1.00s (Approximately 32.88 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - docker.io
  - quay.io
store:
  configFile: /home/podman/.config/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/podman/.local/share/containers/storage
  graphRootAllocated: 48891670528
  graphRootUsed: 32273494016
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 4
  runRoot: /tmp/storage-run-1000/containers
  transientStore: false
  volumePath: /home/podman/.local/share/containers/storage/volumes
version:
  APIVersion: 5.0.3
  Built: 1715299200
  BuiltTime: Fri May 10 00:00:00 2024
  GitCommit: ""
  GoVersion: go1.22.2
  Os: linux
  OsArch: linux/amd64
  Version: 5.0.3

Podman in a container

Yes

Privileged Or Rootless

Rootless

Upstream Latest Release

No

Additional environment details

No response

Additional information

No response

Luap99 commented 3 months ago

Well unix is not a valid container name so it correctly fails to resolve the name

Most likely this is caused by your incorrect DOCKER_HOST, it must be unix:///run/...

flixman commented 3 months ago

Correct! Thank you very much, @Luap99 !