containers / buildah

A tool that facilitates building OCI images.
https://buildah.io
Apache License 2.0
7.49k stars 786 forks source link

buildx --output option causes a build error #3799

Closed jmontleon closed 2 years ago

jmontleon commented 2 years ago

/kind bug

Description

Trying to use podman to build velero with their make container command I get the error Error: unknown flag: --output

Steps to reproduce the issue:

  1. Install podman and podman-docker
  2. export BUILDX_ENABLED=true
  3. clone https://github.com/vmware-tanzu/velero/
  4. run make container

Describe the results you received: Error: unknown flag: --output

Describe the results you expected: Build finished successfully

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

$ podman version
Version:      3.4.4
API Version:  3.4.4
Go Version:   go1.16.8
Built:        Wed Dec  8 16:45:07 2021
OS/Arch:      linux/amd64

I also tried podman 4.0.0 rc2 RPM for Fedora 35. No change.

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.23.1
  cgroupControllers:
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.0.30-2.fc35.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.30, commit: '
  cpus: 12
  distribution:
    distribution: fedora
    version: "35"
  eventLogger: journald
  hostname: AT-802U.montleon.intra
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 5.15.16-200.fc35.x86_64
  linkmode: dynamic
  logDriver: journald
  memFree: 54798798848
  memTotal: 67390660608
  ociRuntime:
    name: crun
    package: crun-1.4.1-1.fc35.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.4.1
      commit: 802613580a3f25a88105ce4b78126202fef51dfb
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  remoteSocket:
    path: /run/user/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: true
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.1.12-2.fc35.x86_64
    version: |-
      slirp4netns version 1.1.12
      commit: 7a104a101aa3278a2152351a082a6df71f57c9a3
      libslirp: 4.6.1
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.3
  swapFree: 25769795584
  swapTotal: 25769795584
  uptime: 10h 39m 34.46s (Approximately 0.42 days)
plugins:
  log:
  - k8s-file
  - none
  - journald
  network:
  - bridge
  - macvlan
  volume:
  - local
registries:
  default-route-openshift-image-registry.apps.jmontleondst.migration.redhat.com:
    Blocked: false
    Insecure: true
    Location: default-route-openshift-image-registry.apps.jmontleondst.migration.redhat.com
    MirrorByDigestOnly: false
    Mirrors: null
    Prefix: default-route-openshift-image-registry.apps.jmontleondst.migration.redhat.com
  default-route-openshift-image-registry.apps.jmontleonsrc.migration.redhat.com:
    Blocked: false
    Insecure: true
    Location: default-route-openshift-image-registry.apps.jmontleonsrc.migration.redhat.com
    MirrorByDigestOnly: false
    Mirrors: null
    Prefix: default-route-openshift-image-registry.apps.jmontleonsrc.migration.redhat.com
  quay-enterprise-quay-enterprise.apps.cam-tgt-21090.qe.devcluster.openshift.com:
    Blocked: false
    Insecure: true
    Location: quay-enterprise-quay-enterprise.apps.cam-tgt-21090.qe.devcluster.openshift.com
    MirrorByDigestOnly: false
    Mirrors: null
    Prefix: quay-enterprise-quay-enterprise.apps.cam-tgt-21090.qe.devcluster.openshift.com
  registry-mirrored-images.apps.jmontleon.mg.dog8code.com:
    Blocked: false
    Insecure: true
    Location: registry-mirrored-images.apps.jmontleon.mg.dog8code.com
    MirrorByDigestOnly: false
    Mirrors: null
    Prefix: registry-mirrored-images.apps.jmontleon.mg.dog8code.com
  search:
  - docker.io
store:
  configFile: /home/jason/.config/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/jason/.local/share/containers/storage
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 34
  runRoot: /run/user/1000/containers
  volumePath: /home/jason/.local/share/containers/storage/volumes
version:
  APIVersion: 3.4.4
  Built: 1638999907
  BuiltTime: Wed Dec  8 16:45:07 2021
  GitCommit: ""
  GoVersion: go1.16.8
  OsArch: linux/amd64
  Version: 3.4.4

Package info (e.g. output of rpm -q podman or apt list podman):

podman-3.4.4-1.fc35.x86_64

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)

No (I did and got the same result with 4.0.0 rc2)

Physical system.

This was brought up here and it sounded like the intention was to swallow the option, but maybe overlooked, or decided that would not be appropriate: https://github.com/containers/podman/issues/11130#issuecomment-893238602

zhangguanzhang commented 2 years ago

buildx is not support now, now:

buildx=build

It's an alias of build

mheon commented 2 years ago

We should investigate adding the option to build, if possible

jmontleon commented 2 years ago

buildx is not support now, now:

buildx=build

It's an alias of build

Yes, as I understand it with the intention of improving docker compatibility: https://github.com/containers/podman/blob/main/RELEASE_NOTES.md#changes-1

And I was curious about the possibility of handling the --output flag as described in the linked comment (https://github.com/containers/podman/issues/11130#issuecomment-893238602)

rhatdan commented 2 years ago

What does the --output flag do?

jmontleon commented 2 years ago

It's linked in the comment I linked: https://github.com/containers/podman/issues/11130#issuecomment-893238602

https://docs.docker.com/engine/reference/commandline/buildx_build/#load

https://docs.docker.com/engine/reference/commandline/buildx_build/#output

rhatdan commented 2 years ago

So with these flags, you would expect to not see the images in buildah images when you are done, or would it be fine if they were there?

jmontleon commented 2 years ago

I think with --output=type=docker it would be expected to see them. As mentioned in the other comment podman's default behavior seems to be equal to --load or --output=type=docker.

On docker after running a build with this I have.

# docker images
REPOSITORY      TAG       IMAGE ID       CREATED          SIZE
velero/velero   main      fff42aff204b   28 seconds ago   111MB
golang          1.17      80d9a75ccb38   4 hours ago      941MB

In podman:

$ docker images
REPOSITORY                TAG         IMAGE ID      CREATED         SIZE
<none>                    <none>      852d9dfae0a3  32 seconds ago  1.02 GB
docker.io/library/golang  1.17        80d9a75ccb38  4 hours ago     963 MB

From the docs it looks like there are other options: https://docs.docker.com/engine/reference/commandline/buildx_build/#output

local, tar, oci,docker,image,registry. I don't have a strong sense of what to expect with each of these. The error only became an issue when trying to use podman in place of docker for testing builds before submitting PRs to the upstream project.

rhatdan commented 2 years ago

Yes it looks like this docker buildx build --output=type=docker ... docker buildx build --output=type=oci ... is the equivalent of podman build --format docker ... podman build --format oci ... (Default)

The others are a little more chalenging, since they probably involve podman build ... podman push XYZ dir:XYZ I am not sure if --tag has the ability to do this.

github-actions[bot] commented 2 years ago

A friendly reminder that this issue had no activity for 30 days.

rhatdan commented 2 years ago

@flouthoc ptal

rhatdan commented 2 years ago

Should this be moved to buildah?

flouthoc commented 2 years ago

I think we can mirror --format with --output=type= at buildah side it self.

nalind commented 2 years ago

The others are a little more chalenging, since they probably involve podman build ... podman push XYZ dir:XYZ I am not sure if --tag has the ability to do this.

The --tag flag can be used to do some of the things in this area, but it currently expects anything other than an image name to look like a name that would be passed to skopeo(1), transport name and all, which is different syntax. It also does not expect to be used when building the same sources for multiple target platforms.

github-actions[bot] commented 2 years ago

A friendly reminder that this issue had no activity for 30 days.

rhatdan commented 2 years ago

@flouthoc aren't you working on this?

flouthoc commented 2 years ago

@rhatdan Yes there is already a PR for this but it requires few changes. I got this.

github-actions[bot] commented 2 years ago

A friendly reminder that this issue had no activity for 30 days.

flouthoc commented 2 years ago

Hi, Support for --output is merged here https://github.com/containers/buildah/pull/3823 should be out in next release. Thanks