Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

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

Open
orblix opened this issue Jan 11, 2023 · 2 comments
Labels
Can Close? Will close in 30 days unless there is a comment indicating why not

Comments

@orblix
Copy link

orblix commented Jan 11, 2023

🐞 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?

@golovasteek
Copy link

Hey! The image gcr.io/distroless/python3
has apparently the entry point set to the /usr/bin/python3.9.

The commands that this rule executes are stored into the script and passed as a commend to the image, but since the entrypoint is set to python, python reads it

I assume the rule should override entry point, since it executes a shell script.

As a work-around you can reset entry point by adding

    docker_run_flags = [
        "--entrypoint=''",
    ],

to you install_postgres rule.

The image you are using doesn't have apt as well, so you may want to use the other base image as well.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days.
Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!

@github-actions github-actions bot added the Can Close? Will close in 30 days unless there is a comment indicating why not label Sep 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Can Close? Will close in 30 days unless there is a comment indicating why not
Projects
None yet
Development

No branches or pull requests

2 participants