Sensu/sensu docker image entrypoint script

I run Sensu go out of a docker image built with some add-ons for the use case and environment specific to my product.

The official Sensu/sensu docker image has an entrypoint script that’s more advanced and functions a bit better than the simple wrapper I’ve been using. I used to have a copy of this script but the machine it was kept on experienced a flash memory failure and I can no longer find this script on the internet. Would it be possible for someone to paste me a copy? It’d save me a bit of work to adapt my current one to poll the backend as it starts prior to initialization.

If this isn’t possible I understand, but thanks anyway!

1 Like

Hey!

So in general, its possible for you to pull the entrypoint or default command scripts from any docker image that you have. Remember docker images really are just tarballs with metadata, its the metadata that docker uses to figure out how to build and run the container. Docker lets you inspect that metadata, and pull content out of containers.

Bad news is right now in the Sensu 5.x series we aren’t using a docker entrypoint. We’re making use of a wrapper script around the sensu-backend specifically that has the logic needed to do the init. Good news is, you can still inspect the image and figure it out.

Here’s what I just did to find the wrapper script:

$ docker image inspect sensu/sensu:5.21.0 | jq .[].ContainerConfig

Entrypoint is null, but the default CMD is not so I can copy out the default command

$ id=$(docker create sensu/sensu:5.21.0)
$ docker cp -L $id:/usr/local/bin/sensu-backend  /tmp/sensu-backend

and now I have the container’s sensu-backend wrapper script on my docker host in /tmp/

In general if you want to get the entrypoint script you can follow a procedure like this:

  1. pull the image

  2. inspect the local copy of the image for the entry point script

    $ docker image inspect whateverimage:tag | jq .[].ContainerConfig.Entrypoint
    

    This will give you an array,

  3. create a container from the image

    $ id=$(docker create whateverimage:tag)
    
  4. copy the content you need out of the local container using that container id.

    $ docker cp $id:/path/src/content  /tmp/content
    

The better news is we are reworking the plumbing for the docker files and planning on moving the logic into an entrypoint and make it available as part of the OSS in the upcoming 6.x series. Watch out for that real soon now.

I hope this helps.

3 Likes

This is a really high quality answer and resolved some things I knew were possible with containers but hadn’t come across figuring out for myself thus. The lack of actual entrypoint explains why I was having trouble locating/extracting it. I’ll see what I can put together on my own, thanks.

2 Likes