29

I try to perform the following command in Ubuntu 14.04:

systemctl enable --now docker-cleanup-dangling-images.timer

I also tried it with sudo, I tried to replace systemctl with service and systemd but nothing works

sudo: systemd: command not found
systemd: command not found
sudo: service: command not foud

How can I execute this command in Ubuntu 14.04 or is there another way to execute the same command?

DenCowboy
  • 13,884
  • 38
  • 114
  • 210

4 Answers4

28

I just encountered this problem myself and found that Ubuntu 14.04 uses Upstart instead of Systemd, so systemctl commands will not work. This changed in 15.04, so one way around this would be to update your ubuntu install.

If this is not an option for you (it's not for me right now), you need to find the Upstart command that does what you need to do.

For enable, the generic looks to be the following:

update-rc.d <service> enable

Link to Ubuntu documentation: https://wiki.ubuntu.com/SystemdForUpstartUsers

rjb-dev
  • 404
  • 4
  • 7
3

Ubuntu 14 and lower does not have "systemctl" Source: https://docs.docker.com/install/linux/linux-postinstall/#configure-docker-to-start-on-boot

Configure Docker to start on boot:

Most current Linux distributions (RHEL, CentOS, Fedora, Ubuntu 16.04 and higher) use systemd to manage which services start when the system boots. Ubuntu 14.10 and below use upstart.

1) systemd (Ubuntu 16 and above):

$ sudo systemctl enable docker

To disable this behavior, use disable instead.

$ sudo systemctl disable docker

2) upstart (Ubuntu 14 and below):

Docker is automatically configured to start on boot using upstart. To disable this behavior, use the following command:

$ echo manual | sudo tee /etc/init/docker.override
chkconfig

$ sudo chkconfig docker on

Done.

Dung
  • 19,199
  • 9
  • 59
  • 54
2

I ran across this while on a hunt for answers myself after attempting to follow a guide using pm2. The goal is to automatically start a node.js application on a server. Some guides call out using pm2 startup systemd, which is the path that leads to the question of using systemctl on Ubuntu 14.04. Instead, use pm2 startup ubuntu.

Source: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-14-04

dhildreth
  • 637
  • 1
  • 6
  • 15
-6

So you want to remove dangling images? Am I correct?

systemctl enable docker-container-cleanup.timer
systemctl start docker-container-cleanup.timer
systemctl enable docker-image-cleanup.timer 
systemctl start docker-image-cleanup.timer

https://github.com/larsks/docker-tools/tree/master/docker-maintenance-units

Seifer
  • 247
  • 3
  • 10
  • I was looking here: https://github.com/openstf/stf/tree/master/docker/extras but yes. That's my main goal (dangling unused images on ubuntu) – DenCowboy May 25 '16 at 13:46
  • 2
    This isn't an answer to my question. I try to perform those commands (which are in the URL) on ubuntu – DenCowboy May 26 '16 at 05:57
  • i kindly suggest you remove your answer as it is causing you to lose -60 points already – Aramis NSR Apr 13 '21 at 09:05