amazon-web-servicesdockeraws-batch

How does AWS Batch override the container command?


I have a docker image built with bazel via py_image rule and specifies a binary target. When supplying the image to AWS Batch, I can't seem to override the default command (which is the binary).

For example, command = ["python"] will give me a main.py: error: unrecognized arguments: python error.

Locally, if I do docker run --entrypoint python image:latest, that does not throw an error.

This is suggesting that the container override is not using the equivalent of the --entrypoint option for docker run. If not, then what is AWS Batch doing?

For reference, the bazel config would look something like:

py_binary(
    name = "main",
    srcs = ["main.py"],
    data = [
        ":config_files",
    ],
    deps = [
        "//src/library/function",
    ],
)

py_image(
    name = "image",
    binary = ":main",
)

Solution

  • The command property of container override overrides the default command (CMD) of the Docker image, which usually is a list of arguments passed to the ENTRYPOINT. If however an ENTRYPOINT is not defined, then CMD is executed as is.

    As per the documentation, it's currently not possible to override the entrypoint.

    For more information on the differences between ENTRYPOINT and CMD, see What is the difference between CMD and ENTRYPOINT in a Dockerfile?