Hi Vincent,

As I wasn't capable to do that with Packer, I finally use Ansible to build 
my Docker Image. 

I wan't able with Packer to take our JDK image 
(idealista/jdk:8u181-stretch-openjdk-headless that is Debian Stretch with 
openJDK installed), then install *systemd* and *systemd-sysv* (using *RUN* 
or similar) and finally declare */sbin/init* as command to launch the 
container by default using *CMD*. 

Needed changes could be seen in this Dockerfile: 

https://github.com/idealista/zookeeper_role/blob/ab15bee3a92a8a62a09d0c7cd33326f5a5936bd9/dockerhub/Dockerfile

We need to install those packages because our ZooKeeper role needs it. As I 
describe in other messages, AFAIK if you want to use systemd, that process 
should be the first process started in that container.

*TL;DR* it's impossible to me to install a package (in this case systemd) 
in docker build phase and then use it to launch the container.

Is it possible to achieve that using Packer instead of a Dockerfile + 
Ansible?

Thanks in advance,
Daniel

El jueves, 21 de febrero de 2019, 20:25:51 (UTC+1), Vincent Rubiolo 
escribió:
>
> Hi Daniel,
>
> Any followups on this issue?
>
> Thanks for the heads-up,
>
> Vincent
> On 2/14/19 8:09 AM, Rickard von Essen wrote:
>
> Since I fail to explain how this works I suggest that you post an example 
> Dockerfile here and I'll translate it to a similar Packer template.
>
> On Thu, Feb 14, 2019 at 2:57 PM Daniel Ortega <danielor...@gmail.com 
> <javascript:>> wrote:
>
>> Hi all,
>>
>> I think there is som confusion of what RUN in a Dockerfile does
>>>
>>
>> I don't agree, my problem it's about something that is called "docker 
>> builder" in Packer cannot be used to build anything (as I cannot execute 
>> any "RUN" command). Maybe it's a semantic question. 
>>
>> 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.
>>>
>>
>> It's clear to me that using some provisioners you can do a workaround for 
>> other cases, but I think that is *not for systemd*. AFAIK, *systemd* 
>> should be the first daemon to start and the last daemon to stop. 
>>
>> Thanks everyone for your suggestions! :)
>>
>> El martes, 12 de febrero de 2019, 20:49:00 (UTC+1), Rickard von Essen 
>> escribió: 
>>>
>>> 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...@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...@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...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/packer-tool/0995fd92-484f-4b8d-9685-3dff1e4aae3d%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/packer-tool/0995fd92-484f-4b8d-9685-3dff1e4aae3d%40googlegroups.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...@googlegroups.com <javascript:>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/packer-tool/CALz9Rt_NvJEt%3DQFkejfx7NqcdAbMMLxiKK3d4JZ0Z%2Bu0y-di7Q%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/packer-tool/CALz9Rt_NvJEt%3DQFkejfx7NqcdAbMMLxiKK3d4JZ0Z%2Bu0y-di7Q%40mail.gmail.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/44674219-7a3e-4d04-852c-ee589d832fcb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to