Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to pass arguments to entrypoint in buildah #2209

Closed
akshatsharma4 opened this issue Mar 9, 2020 · 10 comments
Closed

Not able to pass arguments to entrypoint in buildah #2209

akshatsharma4 opened this issue Mar 9, 2020 · 10 comments

Comments

@akshatsharma4
Copy link

Hi,
I am not able to pass arguments to the entrypoint while building a buildah image(logstash).

Below is how I was passing arguments to my entrypoint in Dockerfile:

ENTRYPOINT ["/usr/share/logstash/config/logstash-entrypoint.sh"]
CMD ["--path.settings", "/etc/logstash/"]
CMD ["-f", "/usr/share/logstash/pipeline/"]

The same thing I tried to do in buildah.sh as:
buildah config --entrypoint '["/usr/share/logstash/config/logstash-entrypoint.sh","--path.settings /etc/logstash/","-f /usr/share/logstash/pipeline/"]' $container

These arguments that are passed to entrypoint is not being read in buildah while it was working as expected in Dockerfile. I am not sure if there is any syntactical error here but I am not facing any problem while building the image.

Kindly help me resolve this.

Best Regards,
Akshat

@TomSweeneyRedHat
Copy link
Member

@akshatsharma4 Can I ask for a bit more information please? Can you tell me:

  • Buildah Version
  • Any error(s) when the bud or config commands run?
  • Can you try running the bud and/or config command again with the debug option? buildah --debug bud ... If so please post the output.
  • Does the image get created? If so can you add the output for buildah inspect {image}

Thanks!

@akshatsharma4
Copy link
Author

akshatsharma4 commented Mar 10, 2020

(TomSweeneyRedHat) edited this reply slightly to make it a bit more readable in the GitHub interface)
@TomSweeneyRedHat Thank you for the response. Here are the details you asked for:

  • buildah version: 1.9.0

  • Any error(s) when the bud or config commands run? -----> I am running those images in my helm chart, there are no errors while runnig logstash chart, it takes all default values and runs just fine. The problem is when I try to increase pipeline.workers by changing that value in my chart. These increased values are not being used and I suspect, it is because the arguments passed to entrypoint is not being considered. Please have a look at the entrypoint command below:
    buildah config --entrypoint '["/usr/share/logstash/config/logstash-entrypoint.sh","--path.settings /etc/logstash/","-f /usr/share/logstash/pipeline/"]' $container

  • Can you try running the bud and/or config command again with the debug option? buildah --debug bud ... If so please post the output. -----> I am not familiar with bud commands. As I mentioned, I am runnig this image in a helm chart, could you please tell me how to debug in kubernetes environment ?

  • Does the image get created? If so can you add the output for buildah inspect {image} ----->
    Yes, the image is getting created and I am able to run it in my helm chart as well.
    output of buildah inspect {image}:

{
    "Type": "buildah 0.0.1",
    "FromImage": "localhost/elk_l:7.0.1-19.12.0",
    "FromImageID": "6bfd3ad245f393c2b45a56e78be4e54761c05336d8506d907efc3bbbb704ce76",
    "Config": "{\"created\":\"2020-03-10T08:57:10.890965504Z\",\"architecture\":\"amd64\",\"os\":\"linux\",\"config\":{\"User\":\"1000\",\"ExposedPorts\":{\"5044\":{},\"9600\":{}},\"Env\":[\"JAVA_HOME=/etc/alternatives/jre_openjdk/\",\"PATH=/usr/share/logstash/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin\",\"LANG=en_US.UTF-8\",\"LC_ALL=en_US.UTF-8\",\"LS_JAVA_OPTS=-Djava.security.egd=file:/dev/./urandom\",\"JARS_SKIP=true\",\"NODE_NAME=ls_node\",\"BATCH_SIZE=125\",\"BATCH_DELAY=5\",\"http_proxy=\",\"https_proxy=\",\"HTTP_PROXY=\",\"HTTPS_PROXY=\",\"JRUBY_OPTS=\"],\"Entrypoint\":[\"/usr/share/logstash/config/logstash-entrypoint.sh\",\"--path.settings /etc/logstash/\",\"-f /usr/share/logstash/pipeline/\"],\"Labels\":{\"BASE_IMAGE\":\"centos:7.7\",\"FROM\":\"scratch\",\"IMAGE_NAME\":\"CENTOS_JAVA11_IMAGE_MICRO\",\"JAVA_RELEASE\":\"11.0.5\",\"MAINTAINER\":\"*************\"}},\"rootfs\":{\"type\":\"layers\",\"diff_ids\":[\"sha256:e4009cf2b5660d3a84cbf2c00e1cc8cd21262220d8c6fdb12786048419618826\",\"sha256:f31d879be8e78a55cfe3b5b59bdca6be926dea1bbd8079f5ca10e8af68f5c576\",\"sha256:b7c6b2705b5868124315c2f516200997325ad72b5661f67a9b8d2da724b1a01e\"]},\"history\":[{\"created\":\"2019-12-16T02:56:02.534822341Z\"},{\"created\":\"2019-12-16T11:01:10.835212766Z\"},{\"created\":\"2020-03-10T08:57:10.890965504Z\",\"created_by\":\"/bin/sh\"}]}",
    "Manifest": "{\"schemaVersion\":2,\"config\":{\"mediaType\":\"application/vnd.oci.image.config.v1+json\",\"digest\":\"sha256:6bfd3ad245f393c2b45a56e78be4e54761c05336d8506d907efc3bbbb704ce76\",\"size\":1253},\"layers\":[{\"mediaType\":\"application/vnd.oci.image.layer.v1.tar\",\"digest\":\"sha256:e4009cf2b5660d3a84cbf2c00e1cc8cd21262220d8c6fdb12786048419618826\",\"size\":58750464},{\"mediaType\":\"application/vnd.oci.image.layer.v1.tar\",\"digest\":\"sha256:f31d879be8e78a55cfe3b5b59bdca6be926dea1bbd8079f5ca10e8af68f5c576\",\"size\":672445952},{\"mediaType\":\"application/vnd.oci.image.layer.v1.tar\",\"digest\":\"sha256:b7c6b2705b5868124315c2f516200997325ad72b5661f67a9b8d2da724b1a01e\",\"size\":396231168}]}",
    "Container": "",
    "ContainerID": "",
    "MountPoint": "",
    "ProcessLabel": "",
    "MountLabel": "",
    "ImageAnnotations": null,
    "ImageCreatedBy": "",
    "OCIv1": {
        "created": "2020-03-10T08:57:10.890965504Z",
        "architecture": "amd64",
        "os": "linux",
        "config": {
            "User": "1000",
            "ExposedPorts": {
                "5044": {},
                "9600": {}
            },
            "Env": [
                "JAVA_HOME=/etc/alternatives/jre_openjdk/",
                "PATH=/usr/share/logstash/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin",
                "LANG=en_US.UTF-8",
                "LC_ALL=en_US.UTF-8",
                "LS_JAVA_OPTS=-Djava.security.egd=file:/dev/./urandom",
                "JARS_SKIP=true",
                "NODE_NAME=ls_node",
                "BATCH_SIZE=125",
                "BATCH_DELAY=5",
                "http_proxy=",
                "https_proxy=",
                "HTTP_PROXY=",
                "HTTPS_PROXY=",
                "JRUBY_OPTS="
            ],
            "Entrypoint": [
                "/usr/share/logstash/config/logstash-entrypoint.sh",
                "--path.settings /etc/logstash/",
                "-f /usr/share/logstash/pipeline/"
            ],
            "Labels": {
                "BASE_IMAGE": "centos:7.7",
                "FROM": "scratch",
                "IMAGE_NAME": "centos:7.7",
                "JAVA_RELEASE": "11.0.5",
                "MAINTAINER": "*************"
            }
        },
        "rootfs": {
            "type": "layers",
            "diff_ids": [
                "sha256:e4009cf2b5660d3a84cbf2c00e1cc8cd21262220d8c6fdb12786048419618826",
                "sha256:f31d879be8e78a55cfe3b5b59bdca6be926dea1bbd8079f5ca10e8af68f5c576",
                "sha256:b7c6b2705b5868124315c2f516200997325ad72b5661f67a9b8d2da724b1a01e"
            ]
        },
        "history": [
            {
                "created": "2019-12-16T02:56:02.534822341Z"
            },
            {
                "created": "2019-12-16T11:01:10.835212766Z"
            },
            {
                "created": "2020-03-10T08:57:10.890965504Z",
                "created_by": "/bin/sh"
            }
        ]
    },
    "Docker": {
        "created": "2020-03-10T08:57:10.890965504Z",
        "container_config": {
            "Hostname": "",
            "Domainname": "",
            "User": "1000",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "5044": {},
                "9600": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "JAVA_HOME=/etc/alternatives/jre_openjdk/",
                "PATH=/usr/share/logstash/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin",
                "LANG=en_US.UTF-8",
                "LC_ALL=en_US.UTF-8",
                "LS_JAVA_OPTS=-Djava.security.egd=file:/dev/./urandom",
                "JARS_SKIP=true",
                "NODE_NAME=ls_node",
                "BATCH_SIZE=125",
                "BATCH_DELAY=5",
                "http_proxy=",
                "https_proxy=",
                "HTTP_PROXY=",
                "HTTPS_PROXY=",
                "JRUBY_OPTS="
            ],
            "Cmd": null,
            "Image": "",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": [
                "/usr/share/logstash/config/logstash-entrypoint.sh",
                "--path.settings /etc/logstash/",
                "-f /usr/share/logstash/pipeline/"
            ],
            "OnBuild": null,
            "Labels": {
                "BASE_IMAGE": "centos:7.7",
                "FROM": "scratch",
                "IMAGE_NAME": "CENTOS_JAVA11_IMAGE_MICRO",
                "JAVA_RELEASE": "11.0.5",
                "MAINTAINER": "***********"
            }
        },
        "config": {
            "Hostname": "",
            "Domainname": "",
            "User": "1000",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "5044": {},
                "9600": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "JAVA_HOME=/etc/alternatives/jre_openjdk/",
                "PATH=/usr/share/logstash/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin",
                "LANG=en_US.UTF-8",
                "LC_ALL=en_US.UTF-8",
                "LS_JAVA_OPTS=-Djava.security.egd=file:/dev/./urandom",
                "JARS_SKIP=true",
                "NODE_NAME=ls_node",
                "BATCH_SIZE=125",
                "BATCH_DELAY=5",
                "http_proxy=",
                "https_proxy=",
                "HTTP_PROXY=",
                "HTTPS_PROXY=",
                "JRUBY_OPTS="
            ],
            "Cmd": null,
            "Image": "",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": [
                "/usr/share/logstash/config/logstash-entrypoint.sh",
                "--path.settings /etc/logstash/",
                "-f /usr/share/logstash/pipeline/"
            ],
            "OnBuild": null,
            "Labels": {
                "BASE_IMAGE": "centos:7.7",
                "FROM": "scratch",
                "IMAGE_NAME": "CENTOS_JAVA11_IMAGE_MICRO",
                "JAVA_RELEASE": "11.0.5",
                "MAINTAINER": "*************"
            }
        },
        "architecture": "amd64",
        "os": "linux",
        "rootfs": {
            "type": "layers",
            "diff_ids": [
                "sha256:e4009cf2b5660d3a84cbf2c00e1cc8cd21262220d8c6fdb12786048419618826",
                "sha256:f31d879be8e78a55cfe3b5b59bdca6be926dea1bbd8079f5ca10e8af68f5c576",
                "sha256:b7c6b2705b5868124315c2f516200997325ad72b5661f67a9b8d2da724b1a01e"
            ]
        },
        "history": [
            {
                "created": "2019-12-16T02:56:02.534822341Z"
            },
            {
                "created": "2019-12-16T11:01:10.835212766Z"
            },
            {
                "created": "2020-03-10T08:57:10.890965504Z",
                "created_by": "/bin/sh"
            }
        ]
    },
    "DefaultMountsFilePath": "",
    "Isolation": "IsolationDefault",
    "NamespaceOptions": [
        {
            "Name": "cgroup",
            "Host": true,
            "Path": ""
        },
        {
            "Name": "ipc",
            "Host": false,
            "Path": ""
        },
        {
            "Name": "mount",
            "Host": false,
            "Path": ""
        },
        {
            "Name": "network",
            "Host": false,
            "Path": ""
        },
        {
            "Name": "pid",
            "Host": false,
            "Path": ""
        },
        {
            "Name": "user",
            "Host": true,
            "Path": ""
        },
        {
            "Name": "uts",
            "Host": false,
            "Path": ""
        }
    ],
    "ConfigureNetwork": "NetworkDefault",
    "CNIPluginPath": "",
    "CNIConfigDir": "",
    "IDMappingOptions": {
        "HostUIDMapping": true,
        "HostGIDMapping": true,
        "UIDMap": [],
        "GIDMap": []
    },
    "DefaultCapabilities": [
        "CAP_AUDIT_WRITE",
        "CAP_CHOWN",
        "CAP_DAC_OVERRIDE",
        "CAP_FOWNER",
        "CAP_FSETID",
        "CAP_KILL",
        "CAP_MKNOD",
        "CAP_NET_BIND_SERVICE",
        "CAP_SETFCAP",
        "CAP_SETGID",
        "CAP_SETPCAP",
        "CAP_SETUID",
        "CAP_SYS_CHROOT"
    ],
    "AddCapabilities": [],
    "DropCapabilities": [],
    "History": [
        {
            "created": "2019-12-16T02:56:02.534822341Z"
        },
        {
            "created": "2019-12-16T11:01:10.835212766Z"
        },
        {
            "created": "2020-03-10T08:57:10.890965504Z",
            "created_by": "/bin/sh"
        },
        {
            "created": "2020-03-10T09:30:37.641357985Z"
        }
    ]
}

Best Regards,
Akshat

@TomSweeneyRedHat
Copy link
Member

@akshatsharma4 thanks for the info. Honestly, I'm not sure how to pull off the debug trick in your environment. However, I have a theory on the issue. It looks like your entrypoint is being set to:

"/usr/share/logstash/config/logstash-entrypoint.sh",
                "--path.settings /etc/logstash/",
                "-f /usr/share/logstash/pipeline/"

I think the last two entries should instead be in the "Cmd" field. Can you try this slightly modified config command please?

buildah config --entrypoint "/usr/share/logstash/config/logstash-entrypoint.sh" --cmd "--path.settings /etc/logstash/ -f /usr/share/logstash/pipeline/" $container

@akshatsharma4
Copy link
Author

@TomSweeneyRedHat
It worked!
I had to make a couple of more changes due to this modification but that is about logstash's configuration.
Really appreciate all your help!

Best Regards,
Akshat

@TomSweeneyRedHat
Copy link
Member

@akshatsharma4 super! Glad we got it figured out.

@akshatsharma4
Copy link
Author

akshatsharma4 commented Mar 13, 2020

@TomSweeneyRedHat
Looks like buildah config --entrypoint "/usr/share/logstash/config/logstash-entrypoint.sh" --cmd "--path.settings /etc/logstash/ -f /usr/share/logstash/pipeline/" $container is not the way to go.

As I mentioned in my previous comment, I had to make a couple of changes after passing cmd in entrypoint, so just out of curiosity, I logged into the logstash pod and ran ps -ef to check which are the scripts Logstash is using to start.
I found, Logstash process was only runnig using /usr/share/logstash/config/logstash-entrypoint.sh and there was no argument passed to entrypoint. which should have not been the case if the argument to entrypoint was considered. This concluded that the extra changes that I had make was because of this.

Basically, my Dockerfile script itself was not correct, which created all the confusion. Seems like, if you pass two different CMD to ENTRYPOINT in Dockerfile, only the last one will be considered. In my Dockerfile I had passed like this:

ENTRYPOINT ["/usr/share/logstash/config/logstash-entrypoint.sh"]
CMD ["--path.settings", "/etc/logstash/"]
CMD ["-f", "/usr/share/logstash/pipeline/"]

Here CMD ["-f", "/usr/share/logstash/pipeline/"] was overriding CMD ["--path.settings", "/etc/logstash/"].
So in case of my buildah script, had to pass only second CMD as an argument to my entrypoint which got it working without any extra changes in the script.

Also, --cmd should not be passed with --entrypoint in buildah config. If you want to pass an argument to entrypoint, it should be passed as:
buildah config --entrypoint '["/usr/share/logstash/config/logstash-entrypoint.sh","-f /usr/share/logstash/pipeline/"]' $container, basically as a comma separated list.
You can refer this link for more details.

Please correct me if any of my understanding is wrong.

Best Regards,
Akshat

@TomSweeneyRedHat
Copy link
Member

@akshatsharma4 Thanks for the feedback, testing, and status. Honestly, I don't know if your understanding is wrong or not offhand, it looks very reasonable and I'll defer to @nalind or others. We'll definitely take a deeper look though thanks to your findings.

@AstraLuma
Copy link

Is this possibly related to containers/podman#4809 ?

@rhatdan
Copy link
Member

rhatdan commented May 7, 2020

Looks possible. Could you check on newer versions?

@AstraLuma
Copy link

Hm. So I want back and looked at my own work. When I dug into this in early February, --entrypoint would accept a JSON array, but --cmd took "shellwords".

I don't think this is the same as the libpod bug above (which was a data schema bug).

To be honest, I'm not sure this is open? You can express multi-argument entrypoint and cmd to buildah config, per the OCI spec. (It says they're both optional arrays of strings.)

tbh, I'm not sure why this bug is open.

@rhatdan rhatdan closed this as completed Aug 6, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants