opencontainers / opencontainers/runc

"exec format error" for ENTRYPOINT pointing to shell script lacking shebang line

Open
#1,773 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
13.5k
Forks
2.3k
Avg merge
2d 8h
Merged PRs (30d)
30

Description

I'm posting this here because error message is raised by a file in this project:

standard_init_linux.go:195: exec user process caused "exec format error"

As an end user I'd like it if somehow it was possible to give a more informative error.

However I have identified what I was doing wrong to cause the error so feel free to close this issue, I mainly wanted it saved somewhere so anyone else having same problem could find the solution in google.

$ docker version
Client:
 Version:      17.04.0-ce
 API version:  1.28
 Go version:   go1.7.5
 Git commit:   4845c56
 Built:        Wed Apr  5 23:33:17 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.12.1-ce
 API version:  1.35 (minimum version 1.12)
 Go version:   go1.9.4
 Git commit:   7390fc6
 Built:        Tue Feb 27 22:20:43 2018
 OS/Arch:      linux/amd64
 Experimental: false

What happened is I had a Dockerfile like:

FROM python:3.6-slim

...

ENTRYPOINT ["pipenv", "run", "celery", "worker"]

Then I wanted to add a "--loglevel=$LOGLEVEL" segment to the entrypoint, but env vars are not interpolated there. So I found the advice to move my startup commands into a shell script and use that as my ENTRYPOINT instead.

I created an entrypoint.sh containing:

pipenv run celery worker --loglevel=$LOGLEVEL $@

and set file permission to executable.

But then when I docker run I get

standard_init_linux.go:195: exec user process caused "exec format error"

This is puzzling because if I manually run ./entrypoint.sh from the command line it works

By trial end error I found that adding the shebang, i.e.

#!/bin/bash
pipenv run celery worker --loglevel=$LOGLEVEL $@

fixed the problem.

I guess this is something to do with how the exec process works vs running in a terminal shell session.

Googling for this error message turned up some quite disparate causes, eg

I wonder if the error message can be more informative or specific to separate problems.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting standard_init_linux.go around line 195 and tracing how the exec format error is propagated. Compare the reported shebang-less script case with the other causes mentioned, including architecture mismatch and file encoding. The issue does not define a specific diagnostic or acceptance criteria, so the desired behavior would need agreement before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.