roadmap icon indicating copy to clipboard operation
roadmap copied to clipboard

Control Docker Desktop via CLI

Open stephen-turner opened this issue 5 years ago • 19 comments

Tell us about your request Most of the Docker Desktop settings are only available via the UI. Several users have commented that it would be useful to be able to control some of them via the CLI, in order to be able to script installation or running of Docker Desktop.

Which service(s) is this request for? Docker Desktop

Are you currently working around the issue? Editing the settings.json file works for settings, although not for operations such as Restart or Quit.

stephen-turner avatar Nov 18 '20 15:11 stephen-turner

Related context https://github.com/docker/for-mac/issues/2359#issuecomment-607154849

myitcv avatar Nov 18 '20 15:11 myitcv

+1

richard-mauri avatar Apr 27 '21 20:04 richard-mauri

Hey! Per https://github.com/docker/cli/issues/3101#issuecomment-845807606, pasting this comment:


Right now, I don't see any command to reset the docker instance of kubernetes via the command line.

As a developer, part of my daily routine is to run a script that sets up my local cluster to a set starting point. I'm currently using Minikube on Mac, but I'd like to try DD for this, as minikube is a little extra complexity that I'm not sure is necessary for my team's needs.

In minikube, you pretty much just run minikube delete followed by minikube start to reset your cluster, whereas in DD it's a button in the UI; It would be really nice to make the button that resets the DD Kubernetes cluster a CLI command, preferably one that will wait until the reset is complete.

kevin-lindsay-1 avatar May 22 '21 01:05 kevin-lindsay-1

This is really important for CI applications. https://github.com/docker/for-mac/issues/2359 has a number of fragile ways to do this that people have been trying to hold together since the old way went away a year or two ago.

rfay avatar May 06 '22 12:05 rfay

Is there an update for this or the docker/for-mac/issues/2359 Issue? I'm looking especially for an auto update mechanism. There is an official Guide to install via cli instead using brew here install-from-cli on MacOs

As far as I have been come I need to login to the headless machines and manually "accept & restart" Docker Desktop for Mac and I like this to happen automatically

violen avatar Oct 13 '22 07:10 violen

There's still no supported way to start Docker Desktop (Windows or mac) from the command line right? Even though there's now unattended install?

rfay avatar Jul 15 '23 19:07 rfay

Having a way to start Docker Desktop from CLI would be a great win for the community. I can verify there are a bunch of users looking for this in their CI setup.

sandipndev avatar Jan 23 '24 06:01 sandipndev

At our company, we'd also like to automate developer environments with Docker Desktop and this is a hurdle for us - currently we are forced to show prompts to user, directing them to click around the UI - not the best experience 😕

jpillor-macquarie avatar Feb 08 '24 23:02 jpillor-macquarie

Could you kindly share which commands / settings, if made available through the CLI, would significantly enhance your operational efficiency?

The following seem to be on the shortlist so far:

  1. Restart Docker Desktop
  2. Quit Docker Desktop
  3. Reset Kubernetes Cluster

We value your input and are interested in understanding your preferences.

KatTomrushka avatar Feb 20 '24 10:02 KatTomrushka

I would find Open Docker Desktop Dashboard really valuable. It's annoying having to click the Go to Dashboard in the menu bar if I have previously closed the dashboard.

colinhemmings avatar Feb 20 '24 11:02 colinhemmings

The listed items are great. It's also easy to look at how well done the Rancher Desktop rdctl and the OrbStack orb commands are done. Both of those solve all the issues discussed here. Thanks for working on this!

rfay avatar Feb 20 '24 17:02 rfay

:see_no_evil: I should probably post the output from the CLI that I cobbled together some Years ago for an internal hackathon; looks like it still somewhat works;

docker desktop command with some initial subcommands;

docker desktop --help

Usage:  docker desktop COMMAND

Commands to interact with Docker Desktop

Management Commands:
  dashboard   Control the Docker Desktop dashboard.
  diagnostics Gather and upload diagnostics bundles for Docker Desktop.

Commands:
  pause       Pause Docker Desktop.
  restart     Restart Docker Desktop.
  resume      Resume Docker Desktop.
  settings    Open Docker Desktop settings.
  shutdown    Stop Docker Desktop.
  start       Start Docker Desktop.

Run 'docker desktop COMMAND --help' for more information on a command.

docker desktop diagnostics to help discovering reporting issues / sending diagnostics;

docker desktop diagnostics --help

Usage:  docker desktop diagnostics COMMAND

Gather and upload diagnostics bundles for Docker Desktop.

Commands:
  check-login Verify HTTP authenticating to login.docker.com and proxy configuration.
  run         Run diagnostic and suggest a way to repair the failures.
  upload      Create and optionally upload a diagnostics bundle.

Run 'docker desktop diagnostics COMMAND --help' for more information on a command.

If Desktop is shutdown (not suspended);

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

docker desktop start
Starting Docker Desktop ...

docker ps -a
CONTAINER ID   IMAGE             COMMAND                  CREATED        STATUS                    PORTS     NAMES
67451e904f48   docs/docstage     "/docker-entrypoint.…"   23 hours ago   Exited (0) 23 hours ago             dockergithubio-docs-1
04aef664a1ff   nginx:alpine      "/docker-entrypoint.…"   5 days ago     Exited (0) 2 hours ago    80/tcp    foo
d3e93ee0e491   docker/swarmkit   "make generate"          6 days ago     Exited (0) 6 days ago               laughing_mayer
d0e1fe510ef7   nginx:alpine      "/docker-entrypoint.…"   13 days ago    Exited (0) 2 hours ago              container_one
042ab952468a   busybox           "sh"                     13 days ago    Exited (0) 2 hours ago              pause_container

Some commands (TBD) to open the GUI from the command-line (e.g. open settings, open the dashboard), but settings could possibly also be managed from the command-line

docker desktop settings
Opening Docker Desktop settings...
docker desktop dashboard open
Opening Docker Desktop dashboard...
Dashboard was opened successfully

Restart and shutdown;

docker desktop restart
Restarting Docker Desktop ...
Docker Desktop was successfully restarted
docker desktop shutdown
Shutting down Docker Desktop ...
Docker Desktop was shut down successfully

Oh, and I had a version with some really (really!) hacky code to manage updates and install/uninstall (to go from a cli-only situation to desktop);

Usage:  docker desktop COMMAND

Commands to interact with Docker Desktop

Management Commands:
  dashboard   Control the Docker Desktop dashboard.
  diagnostics Gather and upload diagnostics bundles for Docker Desktop.
  update      Manage Docker Desktop software updates.

Commands:
  install     Install Docker Desktop.
  pause       Pause Docker Desktop.
  restart     Restart Docker Desktop.
  resume      Resume Docker Desktop.
  settings    Open Docker Desktop settings.
  shutdown    Stop Docker Desktop.
  start       Start Docker Desktop.
  uninstall   Uninstall Docker Desktop.

Run 'docker desktop COMMAND --help' for more information on a command.
docker desktop install
Installing Docker Desktop...
Successfully installed Docker Desktop 4.28 (build 138140)
Starting Docker Desktop ...
docker desktop uninstall
Shutting down Docker Desktop ...
Docker Desktop was shut down successfully
Uninstalling Docker Desktop...
Successfully uninstalled Docker Desktop

And some commands to manage updates;

docker desktop update --help

Usage:  docker desktop update COMMAND

Manage Docker Desktop software updates.

Commands:
  check       Check for Docker Desktop updates.
  download    Download Docker Desktop updates.
  install     Install Docker Desktop updates.

Run 'docker desktop update COMMAND --help' for more information on a command.

(but looks like those are broken, which doesn't surprise me :joy:);

docker desktop update check
Checking if Docker Desktop updates are available ...

thaJeztah avatar Feb 20 '24 17:02 thaJeztah

I would find Open Docker Desktop Dashboard really valuable. It's annoying having to click the Go to Dashboard in the menu bar if I have previously closed the dashboard.

@colinhemmings @KatTomrushka you can do this today, link or open URI docker-desktop://dashboard/open

jpillor-macquarie avatar Feb 20 '24 22:02 jpillor-macquarie

Could you kindly share which commands / settings, if made available through the CLI, would significantly enhance your operational efficiency?

We automate pulls and other normal docker commands, however our SSO tokens have very short TTLs, so they often expire. This results in docker commands returning something like docker login to proceed, unfortunately docker login only works if you're logging into docker hub without SSO. In our case the error is more confusing because the user does it, and it doesn't fix it. The user actually needs to open docker desktop, and then click login, and then go through the SSO process.

As a partial step towards this, it'd be great if we could trigger login and take the user straight to the login screen.

This action, and any other actions, could be triggered via docker desktop plugin, or via local RPC endpoint (which the plugin would use), or via docker-desktop URIs - however these would offer the least functionality. A documented API endpoint would be preferred :)

jpillor-macquarie avatar Feb 20 '24 23:02 jpillor-macquarie

Is there honestly no way to restart Docker Desktop on Windows via CLI?

Mine has a weird bug where my containers just freeze after about 24-48 hours and I have to restart them, which I think is WSL related, but currently I have to do "wsl --shutdown" and then VNC in to click a "Restart" button on the modal that pops up, and it seems fairly ridiculous there doesn't appear to be an obvious way I can just restart the whole of Docker Desktop via a command or two without having to resort to that?

seliquity avatar Nov 03 '24 12:11 seliquity

Yes, @seliquity good point and restart is definitely included in the scope. Thanks for the feedback, keep it coming!

KatTomrushka avatar Nov 04 '24 14:11 KatTomrushka

Please could you consider adding a feature like git config to allow us to get/set configuration for docker desktop. We currently alter the docker settings file using jq, but when we do so:

  1. We do not know that the file format will not change.
  2. Docker desktop complains that its settings file has been changed, which is alarming for users.
  3. Even the location of the settings file is not certain.

A CLI contract would help here. Additionally, CLI start/ stop/ restart and access to the troubleshoot commands would be very helpful.

ch-tstrickland avatar Nov 25 '24 12:11 ch-tstrickland

Loving the new start/stop/etc feature. Are you going to consider a config API? Should I ask in a separate ticket - or perhaps I've missed a preexisting ticket? Many thanks.

ch-tstrickland avatar Dec 19 '24 20:12 ch-tstrickland

Resetting the kubernetes cluster via the docker desktop CLI would be extremely useful for our team. That is the one step of our local development flow that we cannot automate with docker desktop currently. It requires a manual step to open the UI and click the "reset" button.

joeykmh avatar Mar 20 '25 06:03 joeykmh