Code Monkey home page Code Monkey logo

Comments (14)

dimisjim avatar dimisjim commented on September 23, 2024 3

@nywilken

any update on this?

it's a very fundamental feature that this plugin lacks

from packer-plugin-docker.

josh-m-sharpe avatar josh-m-sharpe commented on September 23, 2024 1

I've run into this issue and it's super unexpected. packer should definitely not clobber CMD/ENTRYPOINT if it's not defined in the packer script.

from packer-plugin-docker.

josh-m-sharpe avatar josh-m-sharpe commented on September 23, 2024 1

I mean that was my "workaround" too -- setting ENTRYPOINT everywhere back to some 'default'. This is not a solution.

from packer-plugin-docker.

northben avatar northben commented on September 23, 2024

Any update on this issue? I am facing the same problem. The official doc doesn't explain the current behavior.

from packer-plugin-docker.

CeliaS1 avatar CeliaS1 commented on September 23, 2024

Our development team is facing the same problem. Hope a fix can be made :)

from packer-plugin-docker.

CeliaS1 avatar CeliaS1 commented on September 23, 2024

To be more precise :
Here is the definition of the 'Cmd' and 'Entrypoint' fields on a base image pulled from DockerHub :

# docker inspect debian:bullseye-slim -f '{{ .ContainerConfig.Cmd }}
[/bin/sh -c #(nop)  CMD ["bash"]]
# docker inspect debian:bullseye-slim -f '{{ .ContainerConfig.Entrypoint }}
[]

When we build an image derived from this Debian base image with Packer, even if we only add a LABEL, the 'Cmd' and 'Entrypoint' fields are modified, which is not the case when using a Dockerfile :

# docker inspect <our_image> -f '{{ .ContainerConfig.Cmd }}
[]
# docker inspect <our_image> -f '{{ .ContainerConfig.Entrypoint }}
[/bin/sh]

Note : Extract from the Packer's template, which is very simple :

source "docker" "debian-bullseye" {
  image  = 'debian:bullseye-slim'
  commit = true
  changes = [
    "LABEL env=devel"
  ]
}

from packer-plugin-docker.

CeliaS1 avatar CeliaS1 commented on September 23, 2024

It seems that this problem can't be solved easily. The behavior comes from the way the Docker builder works : it is derived from the docker commit command, and Packer run the container with run_command which define the entrypoint to /bin/sh :

["-d", "-i", "-t", "--entrypoint=/bin/sh", "--", "{{.Image}}"]

That's the reason why the CMD and ENTRYPOINT are changed.
The Docker builder is a beautiful plugin but, unfortunately, not very usable.

from packer-plugin-docker.

CeliaS1 avatar CeliaS1 commented on September 23, 2024

Hi,
Maybe we can imagine a simple solution like this :
when a Docker image is build and do not define CMD nor ENTRYPOINT values, the Docker Plugin get this parameters from the base image (defined in the source.docker block) and automatically add them into the "changes" array, so that they would be taken into account by the docker commit --change command.

What do you think about it ?
Thanks.

from packer-plugin-docker.

huyz avatar huyz commented on September 23, 2024

Any effective workarounds?

from packer-plugin-docker.

dimisjim avatar dimisjim commented on September 23, 2024

yeah, just use another container builder

from packer-plugin-docker.

huyz avatar huyz commented on September 23, 2024

@dimisjim suggestions?

from packer-plugin-docker.

dimisjim avatar dimisjim commented on September 23, 2024

https://github.com/docker/buildx

from packer-plugin-docker.

huyz avatar huyz commented on September 23, 2024

I think I figured out a workaround.

Instead of leaving ENTRYPOINT blank, I set ENTRYPOINT to a command that is effectively equivalent to nothing but that Packer won't clobber:

    "ENTRYPOINT [\"/bin/sh\", \"-c\", \"exec \\\"$0\\\" \\\"$@\\\"\"]",

Ugly but seems to work.

from packer-plugin-docker.

huyz avatar huyz commented on September 23, 2024

@josh-m-sharpe you're right, it's not a solution. It's a workaround lol

from packer-plugin-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.