1

I have docker installed in my system but I dont want docker to start on startup or in the background but only needs to run when it is required for me. So I have disabled docker daemon using

sudo systemctl stop docker.service
sudo systemctl disable docker.service

This prevented docker from running on startup and in the background . The problem is if I want to work with docker images then I have to again restart the docker services sudo systemctl restart docker.service and after my use I have to disable it. Without docker daemon running docker images returns

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Is there a way to run docker images without docker daemon running? Else is there a way to hard code to disable the docker daemon after use?

3 Answers 3

3

Is there a way to run docker images without docker daemon running?

No.

Is there a way to hard code to disable the docker daemon after use?

You could create a cron job that is executed every few minutes) that executes

sudo systemctl disable docker.service

based on an event. That event could be a check on a process id. docker stats is a likely candidate. That one could be used to decide if a container is currently active or not.

Without docker daemon running docker images returns an error.

That command you could change to sudo systemctl enable docker.service && docker images so it starts the service 1st and then starts docker.

1

@Rinzwind

sudo systemctl enable docker.service && docker images will not work

Well one another ways is to modify your command which

  • Start docker daemon
  • Execute docker images
  • Stop docker daemon

sudo systemctl start docker.service && docker images && systemctl stop docker.service

1
  • 1
    It answers the last paragraph of the original question I think.
    – Wirewrap
    Commented Apr 20, 2020 at 8:48
1

With Docker no. But there are solutions.

Docker requires a service as it's more of a client-server model.

Partially I suspect it's due to Docker (the company) wanting to support Non Linux based OS:es that run the container engine in a VM. making the client server model a better fit

Of course having a docker daemon running and requiring elevated privileges is somewhat a security weakness

Run podman instead.

It's docker-compatible written in GO and allows you to build & run docker images without requiring any docker-service or even having docker installed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .