aws / aws-codebuild-docker-images

Official AWS CodeBuild repository for managed Docker images http://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref.html
Other
1.11k stars 973 forks source link

Docker buildx not found in image aws/codebuild/standard:6.0 #653

Closed varad11 closed 1 year ago

varad11 commented 1 year ago

Describe the bug docker: 'buildx' is not a docker command

To Reproduce Steps to reproduce the behavior:

  1. Create a build project with environment image set to aws/codebuild/standard:6.0
  2. Select check box "Privileged" to enable docker builds.
  3. Open buildspec.yml and add below commands.
    - export DOCKER_BUILDKIT=1 #enable buildkit for using buildx.
    - docker buildx ls
  4. Trigger build.
  5. See error
    docker: 'buildx' is not a docker command.
    Command did not exit successfully docker buildx ls exit status 1

Expected behavior Should print the builder instances before completing the build.

Logs


[Container] 2023/06/12 15:20:53 Running command docker info
Client:
 Context:    default
 Debug Mode: false
Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 20.10.24
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7937501cf608283f883dbfddb71e4e0aebfeeabd
 runc version: v1.1.5-0-gf19387a6
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.14.291-218.527.amzn2.x86_64
 Operating System: Ubuntu 22.04.2 LTS (containerized)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.644GiB
 Name: <SOME_NAME>
 ID: <SOME_ID>
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine

Platform (please complete the following information): N/A

Additional context N/A

SunsetYe66 commented 1 year ago

This might be tracked by #625 ? @Dylan-AWS @subinataws Any updates on this particular issue?

I'm feeling extremely frustrated as this issue has been pending for over a month now, and the community is not receiving any updates yet. In contrast, GCP was able to resolve a similar issue within a day. (ref https://github.com/GoogleCloudPlatform/cloud-sdk-docker/issues/331 )

varad11 commented 1 year ago

Buildx seemed to work on standard:6.0 image a few days back, but now it's not working. Temporarily I am able to create builds by adding commands in my buildspec.yml to download and run the latest release of buildx plugin. This works, but it's an extra hassle and the builds take more time. Ideally I guess the docker version provided by codebuild must include buildx rather than we manually downloading it.

Antonio-AWS commented 1 year ago

This should be resolved in next release.

In the meantime if you need to get buildx working in your Standard:6.0 build you can add the following to your buildspec.

- mkdir -p /usr/local/lib/docker/cli-plugins 
- curl -L https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-amd64 -o /usr/local/lib/docker/cli-plugins/docker-buildx 
- chmod +x /usr/local/lib/docker/cli-plugins/docker-buildx 
- export DOCKER_BUILDKIT=1 #enable buildkit for using buildx.
- docker build ...
Antonio-AWS commented 1 year ago

Fixed in latest release: https://github.com/aws/aws-codebuild-docker-images/pull/660/commits/182bbfdc86ff9b35ddf5d96f9b9140c46af14438#diff-0ea4e3f07c5eba7b3bbd22e5109de147c49f958d539eaa2d83fc61407d7bde21