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

Packer docker builder does not reset ENTRYPOINT properly #7487

Closed
bertramn opened this issue Apr 10, 2019 · 8 comments
Closed

Packer docker builder does not reset ENTRYPOINT properly #7487

bertramn opened this issue Apr 10, 2019 · 8 comments
Labels

Comments

@bertramn
Copy link

We are using packer to build a container with a parent that includes an entrypoint. In the packer build we "reset" entrypoint with ENTRYPOINT []. Unfortunately the container is being committed with the entrypoint of the parent still in place.

Doing this in a Dockerfile gets rid of the entrypoint from parent:

FROM ep-issue:parent
ENTRYPOINT []
CMD []

While the same in packer version does not:

{
  "builders": [
    {
      "type": "docker",
      "image": "ep-issue:parent",
      "pull": "false",
      "commit": "true",
      "changes": [
        "ENTRYPOINT []",
        "CMD []"
      ]
    }
  ],
  "post-processors": [
    {
      "type": "docker-tag",
      "repository": "ep-issue",
      "tag": "child2"
    }
  ]
}
@azr azr added builder/docker community-supported-plugin denotes requests for plugins that are supported by the community, not by HashiCorp engineers labels Apr 10, 2019
@rickard-von-essen
Copy link
Collaborator

This is actually a issue with the Docker cli:

$ docker inspect postgres  --format "{{ .Config.Entrypoint }}"
[docker-entrypoint.sh]

$ docker run -d --name testing postgres
4267a7f6f166e9009fdceb4ce232307482c87cf03ac14aa0f5e5aae38cfdddee

$  docker commit --change "ENTRYPOINT []" 4267a7f6f166
sha256:37903e8002b37273bb368eb00fe3333a0ce4fb31c34c81fb7ffac6e0f714dd11

$ docker inspect sha256:37903e8002b37273bb368eb00fe3333a0ce4fb31c34c81fb7ffac6e0f714dd11 --format "{{ .Config.Entrypoint }}"
[docker-entrypoint.sh]

I suggest that you open an issue with Moby and link it here.

@rickard-von-essen rickard-von-essen added the stage/waiting-on-upstream This issue is waiting on an upstream change label Apr 10, 2019
@azr
Copy link
Contributor

azr commented Apr 10, 2019

The weird thing is if I pause packer (using debug mode) and run for example docker commit -c 'ENTRYPOINT ["tini", "--"]' -c 'CMD ["top"]' ( the same command packer runs) the resulting image will get the ENTRYPOINT/CMD fields updated only out of packer.

@azr
Copy link
Contributor

azr commented Apr 10, 2019

related: moby/moby#29502

@SwampDragons SwampDragons removed the community-supported-plugin denotes requests for plugins that are supported by the community, not by HashiCorp engineers label Apr 19, 2019
@javierbertoli
Copy link

javierbertoli commented May 5, 2019

I hit this issue too, and found a solution. This

"builders": [
    {
      "type": "docker",
      "image": "some_image",
      "pull": true,
      "commit": true,
      "changes": [
        "ENTRYPOINT [\"\"]",
        "CMD [\"\"]"
      ]
    }
  ],

effectively reset the entrypoint to [] for me.

As I have never used it before, I'm not sure if this is a recent change in the way to specify it or a bug in the documentation, but 'works for me'. Hope this helps.

@azr
Copy link
Contributor

azr commented May 6, 2019

One thing we could do is run "ENTRYPOINT []" & "CMD []" by default in a docker build ? 🤔

@SKoschnicke
Copy link

Just ran into this. Using a base image with an ENTRYPOINT = null, packer in version 1.4.0 sets the entrypoint to /bin/sh which breaks the image because the process to run is defined solely in CMD. Is it required to change the entrypoint, if such a change was not specified in the changes section of the packer config?

Also, docs say that ENTRYPOINT in changes can only be set to a string, which contradicts the workaround of @javierbertoli but I'm testing it right now, anyway.

@ghost
Copy link

ghost commented Mar 19, 2021

This issue has been automatically migrated to hashicorp/packer-plugin-docker#13 because it looks like an issue with that plugin. If you believe this is not an issue with the plugin, please reply to hashicorp/packer-plugin-docker#13.

@ghost ghost closed this as completed Mar 19, 2021
@ghost
Copy link

ghost commented Apr 19, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Apr 19, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants