stop and disable systemctl service

28 views
Skip to first unread message

Jeeva Chelladhurai

unread,
Jul 22, 2019, 1:56:22 PM7/22/19
to Packer
Hello All,

I am building an AMI using packer. I want to install docker on my target image however the docker should be in stopped state. In my provisioner I have stopped and disabled the docker service, nonetheless, when I launch a new VM the docker service is enabled and running. 

Please guide me how to disable a service in packer.

I'm building an ubuntu 18.04 image.

Thanks,
Jeeva'

Rickard von Essen

unread,
Jul 22, 2019, 2:17:22 PM7/22/19
to packe...@googlegroups.com
Could you provide details of what you have done and how you verified it? 

--
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/8a9941fd-76ee-4e04-8061-35ee2b4f8966%40googlegroups.com.

Jeeva Chelladhurai

unread,
Jul 23, 2019, 7:08:10 AM7/23/19
to Packer
I am manually testing it.. below is my provisioner and log..

"provisioners": [{
    "type": "shell",
    "pause_before": "30s",
    "inline": [
      "curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -",
      "sudo add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable\"",
      "sudo apt-get update",
      "sudo apt-get install -y docker-ce",
      "sudo usermod -aG docker ubuntu",
      "curl -sSL http://sjeeva.github.io/getcompose | sudo sh",
      "sudo mkdir /data",
      "sudo systemctl stop docker",
      "sudo systemctl disable docker",
      "sudo cp /tmp/docker.service /lib/systemd/system/docker.service"
    ]
  }]

    amazon-ebs: docker-compose version 1.24.1, build 4667896b is installed
==> amazon-ebs: Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
==> amazon-ebs: Executing: /lib/systemd/systemd-sysv-install disable docker
==> amazon-ebs: Pausing after run of step 'StepProvision'. Press enter to continue.



On Monday, July 22, 2019 at 11:47:22 PM UTC+5:30, Rickard von Essen wrote:
Could you provide details of what you have done and how you verified it? 

On Mon, Jul 22, 2019, 19:56 Jeeva Chelladhurai <sje...@gmail.com> wrote:
Hello All,

I am building an AMI using packer. I want to install docker on my target image however the docker should be in stopped state. In my provisioner I have stopped and disabled the docker service, nonetheless, when I launch a new VM the docker service is enabled and running. 

Please guide me how to disable a service in packer.

I'm building an ubuntu 18.04 image.

Thanks,
Jeeva'

--
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 packe...@googlegroups.com.

Rickard von Essen

unread,
Jul 23, 2019, 10:40:15 AM7/23/19
to packe...@googlegroups.com
Most likely you have some other enabled unit that depends on docker.service and hence it's started.

Use systemctl list-dependencies --reverse docker.service to see what depends on it.

Also with systemd by default docker.service is started if anything accesses /var/run/docker.sock (e.g. runs the docker command) 

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/e3691a88-091d-4208-b89f-eaedd6358d2d%40googlegroups.com.

Jeeva Chelladhurai

unread,
Jul 23, 2019, 3:52:47 PM7/23/19
to Packer
docker CLI starts docker service. In other words, as soon as I call docker command it starts the docker service

Thanks,
Jeeva 
Reply all
Reply to author
Forward
0 new messages