I think there is som confusion of what RUN in a Dockerfile does. It
executes the command during the build of the image. That would be handled
by a shell provisioner in Packer.

What process gets started when you *run* the container from the resulting
image is handled by ENTRYPOINT and CMD those can be set in packer with the
changes 1).

So to produce a image that runs systemd do:

a) shell provisioner to install systemd and services
b) change the ENTRYPOINT/CMD in changes to run systemd.

1) https://packer.io/docs/builders/docker.html#changes

// Rickard

PS. Multiprocess containers can (and should) really be questioned.

On Tue, Feb 12, 2019 at 6:14 PM Vincent Rubiolo <
vincent.rubi...@datameer.com> wrote:

> Hi Daniel,
> On 2/12/19 2:29 AM, Daniel Ortega wrote:
>
> We want to use our Java docker image (tagged as 
> *idealista/8u181-stretch-openjdk-headless
> <https://hub.docker.com/r/idealista/jdk/tags>* in Docker Hub) which is
> based in Debian Stretch Slim.
>
> This image *doesn't have systemd* (neither official image, nor our
> derived image one), so this package should be installed to be used later to
> configure our services. AFAIK, if you want to use systemd to manage
> services, this process should be the first -> should be present in Docker
> run command. But the problem is, before installation /lib/system/systemd is
> not present, so the container cannot start. This could be solved using RUN
> when you are using Dockerfiles, because that commands are executed in the
> image "build phase". You can install systemd before and execute
> /lib/system/systemd at container startup.
>
> As Rickard said, you can use a shell provisioner to run any command you
> want (in this case the one to start systemd) once your container is up with
> Packer. Another solution is to override the RUN command (as per
> https://www.packer.io/docs/builders/docker.html#run_command) to specify
> what you want.
>
> So in short I'd advise:
>
>    1. Start your container with Packer using the default settings.
>    2. Install the packages you want (either via a shell or Ansible
>    provisioner), like systemd.
>    3. In your shell provisioner, manually start systemd, then use it to
>    configure the services
>
> AFAIK, systemd must be running when you use commands like 'service' but it
> does not need to be started when the container starts (there are ways to do
> that if needed).
>
> On a related note, I had a similar issue with the container not starting,
> because the default Packer 'docker run' command relies on /bin/bash +  not
> having an entrypoint set (cf
> https://github.com/hashicorp/packer/issues/6920). The changes was made
> but later reverted because of backward compatibility issues. You might find
> the issue useful in your case tool.
>
> Let us know how it goes,
>
> Vincent
>
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in
> violation of those guidelines may result in your removal from this mailing
> list.
>
> GitHub Issues: https://github.com/mitchellh/packer/issues
> IRC: #packer-tool on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Packer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to packer-tool+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/72c11e2b-38c1-2890-8ba0-ae3da7012f40%40datameer.com
> <https://groups.google.com/d/msgid/packer-tool/72c11e2b-38c1-2890-8ba0-ae3da7012f40%40datameer.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to packer-tool+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/CALz9Rt95T1LBKUrJPYEkg_4SdqtMzxDkC_5wtDK3ohS_3m0wAw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to