Puppet and Docker: docker exec doesn't start puppet container automatically.

0 votes

 I need to run the command docker exec to start the container and run the following commands to get it started and create the ca certificates in its ssl directory:

puppet master --verbose 
service puppetmaster start
chkconfig puppetmaster on

Here's the dockerfile for a puppet container for a certificate authority.This doesn't start automatically,

FROM centos:6
RUN yum update -y
RUN rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm
RUN yum install -y ruby puppet-server  
ADD puppet.conf /etc/puppet/puppet.conf

VOLUME ["/var/lib/puppet/ssl/"]

RUN puppet master --verbose 

CMD service puppetmaster start
CMD chkconfig puppetmaster on
CMD []

The container can be started using the run(note that I named the image ca-puppet):

docker run -d -p 9140:9140 -it --name ca-puppet \
-v /puppet-host/ssl:/var/lib/puppet/ssl \
ca-puppet bash
Aug 30 in Puppet by Sheeba

1 answer to this question.

0 votes

There can only be one CMD instruction in a Dockerfile. If you list more than one CMD then only the last CMD will take effect.

If the user specifies arguments to docker run then they will override the default specified in CMD.

Try not daemonizing puppet and start it as the default container command via something like:

CMD puppet master --verbose --no-daemonize

And use the Docker host to manage it (via restart policy, etc.).

answered Aug 30 by Sirajul
• 38,420 points

Related Questions In Puppet

0 votes
1 answer

Is it possible to install puppet agent in a docker container on linux?

Hey @Janice, this is pretty simple. Create ...READ MORE

answered Mar 12 in Puppet by Jason
0 votes
1 answer
0 votes
1 answer

Puppet+Docker: How do i configure my docker container to use a NFS volume through a Hiera config file?

If using Hiera, configure the docker::volumes class in the ...READ MORE

answered Aug 14 in Puppet by Sirajul
• 38,420 points
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,920 points
0 votes
0 answers

Puppet+Docker: pull an image and launch a container

I am experimenting on integrating a containerization ...READ MORE

Aug 13 in Puppet by Sam
• 4,120 points