bazelbuild / bazelbuild/rules_docker

container_run_and_commit failes to create image: "/usr/bin/python3.9: can't open file '//sh': [Errno 2] No such file or directory"

Open
#2,210 3 comments 0 reactions 0 assignees View on GitHub
Can Close?
Dominant language
Starlark
Stars
1.1k
Forks
689
PR merge metrics
No merged PRs in 30d

Description

# 🐞 bug report

### Affected Rule

The issue is caused by the rule:
container_run_and_commit

### Is this a regression?

Yes.

### Description

Trying to create a container image with the container_run_and_commit rule fails.

## 🔬 Minimal Reproduction

Trying to create a simple image with postgresql installed fails:
```
container_pull(
name = "py3_debug_image_base",
registry = "gcr.io",
repository = "distroless/python3",
digest = "sha256:84b5e6a7e091754b31b34e65307c2f60a4ab1c1ceb583db55da9bbe1f272498a",
)

container_run_and_commit(
name = "install_postgres",
commands = [
"apt-get update",
"apt-get install -y postgresql",
],
image = "@py3_debug_image_base//image",
)
```

## 🔥 Exception or Error



bazelisk build package/api:install_postgres --define=VERBOSE_LOGS=1

INFO: Analyzed target //package/api:install_postgres (0 packages loaded, 12691 targets configured).
INFO: Found 1 target...
ERROR: /home/enzer/projects/package/api/BUILD:27:25: Action package/api/install_postgres_commit.tar failed: (Exit 1): install_postgres.build failed: error executing command (from target //package/api:install_postgres) bazel-out/k8-fastbuild/bin/package/api/install_postgres.build

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
Loaded image: bazel/image:image
/usr/bin/python3.9: can't open file '//sh': [Errno 2] No such file or directory
648e2f1fa2072c0ec21cb92b69eb8d5d9e172f9a4c5fe9b5a24908bc7433a16e
Target //package/api:install_postgres failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 4.770s, Critical Path: 3.21s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully

## 🌍 Your Environment

**Operating System:**

  

Linux or-workstation 5.10.0-20-cloud-amd64 #1 SMP Debian 5.10.158-2 (2022-12-13) x86_64 GNU/Linux

**Output of `bazel version`:**

  

Bazelisk version: v1.15.0
Build label: 6.0.0-pre.20221020.1
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Oct 27 16:53:10 2022 (1666889590)
Build timestamp: 1666889590
Build timestamp as int: 1666889590

**Rules_docker version:**

  

v0.25.0

**Anything else relevant?**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.