Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI for Docker For Mac #882

Closed
nmcalabroso opened this issue Nov 1, 2016 · 14 comments
Closed

CLI for Docker For Mac #882

nmcalabroso opened this issue Nov 1, 2016 · 14 comments

Comments

@nmcalabroso
Copy link

CLI for Docker For Mac

Feature Request

Is it possible to have all the features that can be done via the GUI of Docker for Mac to some sort of CLI? This request is coming from an annoying issue from #412 that is holding back people who want to use their containers both for GNU/Linux and MacOS. Thank you!

@dsheets
Copy link
Contributor

dsheets commented Jan 16, 2017

#412 was resolved in Beta 33 and support was improved in Beta 35 or 36. Do you still need this functionality?

@quantonganh
Copy link

Do you still need this functionality?

Yes, I still need this.

Quoted from this: https://forums.docker.com/t/how-to-run-docker-for-mac-as-a-service-or-deamon/18728

Expected behavior

There should be a way to install Docker For Mac as a service which runs at system startup.

Actual behavior

Docker for Mac Beta seems to require a ui based app "Docker.app" to run in a graphical user session. I could not figure out any way on how to start the Docker environment using cli tools.
The older Docker Toolbox allowed the use of e.g. docker-machine command to start its VirtualBox based environment. This allowed to create start-up scripts, to create a server ecosystem at system startup without a user to login.

Information

We'd like to use the great "Docker for Mac Beta" asap in a productive environment using the elegant integration with the native MacOS virtualization framework. So it would be of cause more robust and user friendly to install and run Docker and it's containers as system services automatically and independent on a user-login.
I tried to find suitable CLI tools in the Docker.app package but haven't been successful.

Is there any recommended way to install and run "Docker for Mac Beta" and its container as a service automatically at system startup?

@samoht
Copy link
Contributor

samoht commented Jan 31, 2017

There is no short-term plan to add a command-line interface to Docker for Mac, so closing as "won't fix" (at least in the short/middle term). We understand that this is an important component for some use-cases, but we have no plans to work on this currently.

@martinm82
Copy link

This is kind of insane. On one side you are developing a tool that is supposed to isolate apps/services and make it easy to deploy them everywhere but if it is about deploying the tool itself on a large number of macOS nodes than that is not supported and won't be.
Right now I am using Ansible to deploy D4M on the nodes and need to pause Ansible in order to configure it manually.

Any plans to make the D4M UI open source so that this feature could be contributed to you?

@martinm82
Copy link

martinm82 commented Aug 23, 2017 via email

@lyndsey-ferguson
Copy link

I really need to install Docker.app via the command line. sudo /Applications/Docker.app/Contents/MacOS/Docker --quit-after-install --unattended does not launch the tools needed. Unless I run the app by double clicking it in the GUI, docker ps complains about the daemon not running.

I use ansible to set up many Mac minis for Continuous Integration and it is not reasonable that I have to log into each machine via VNC to get Docker to completely install.

@djs55
Copy link
Contributor

djs55 commented Jan 1, 2018

@lyndsey-ferguson the argument --quit-after-install shuts everything down after the installation. Try either removing this argument or re-launching the app using open /Applications/Docker.app (as a regular user i.e. without sudo) afterwards.

@lyndsey-ferguson
Copy link

lyndsey-ferguson commented Jan 1, 2018

Thanks, I tried that but the Docker.app doesn't stops responding after a few seconds with 0% CPU activity. I left it running for 30 minutes with the thought that it was so busy that it was not responding on the main thread, but the "not responding" status (in the Activity Monitor app) did not change.

@lyndsey-ferguson
Copy link

The problem was that, in my experimentation, I had started the /Library/LaunchDaemons/com.docker.vmnetd.plist LaunchDaemon. Unloading that allowed me to get this setup properly.

@martinm82
Copy link

martinm82 commented Jan 2, 2018

So in my setup we need to have an open session (logged in) with a specific user.

In order to properly configure Docker I need to run the app (with --quit-after-install --unattended) two times, once running as root user to configure properly the vmnetd daemon.
Afterwards I need to re-run it but as the user that will be logged-in to configure the rest (settings for D4M like CPUs, memory, etc.).

Configuring automatically additional mount points was as well not straight forward but after some time I figured out that the configuration itself is stored in a git repo (/Users/{{ docker_username }}/Library/Containers/com.docker.docker/Data/database/) in the following file /Users/{{ docker_username }}/Library/Containers/com.docker.docker/Data/database/com.docker.driver.amd64-linux/mounts.

My custom launchd configuration as well looks a bit different:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.tomtom.docker</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/bin/open</string>
      <string>-a</string>
      <string>/Applications/Docker.app</string>
      <string>--args</string>
      <string>--unattended</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

If I don't specify the additional args I get after a reboot always the welcome dialog and Docker won't start-up (even if I disable the welcome message in the settings.json.

@lyndsey-ferguson
Copy link

Thanks @martinm82, I will use that if we experience the same issue.

@jensgreen
Copy link

We managed to do an unattended install that automatically starts the Docker daemon and launches it on login without the "We are whaly happy to have you" popup.

Steps:

  • Install the Docker Desktop .dmg (we used 2.0.0.3)
  • Run /Applications/Docker.app/Contents/MacOS/Docker --quit-after-install --unattended as root
    • (unless: pgrep -q -f /Library/PrivilegedHelperTools/com.docker.vmnetd)
  • Set the following lines in~/Library/Group Containers/group.com.docker/settings.json:
    "displayedWelcomeMessage" : true,
    "displayedWelcomeWhale" : true,
    
  • Run /usr/bin/open -g -j -a /Applications/Docker.app
    • (unless: pgrep -q -f /Applications/Docker.app/Contents/MacOS/Docker)

The Docker daemon is launched and starts up successfully after reboot.

@rfay
Copy link

rfay commented Jul 31, 2019

As mentioned in #2359 (comment) the

/Applications/Docker.app/Contents/MacOS/Docker --unattended
/Applications/Docker.app/Contents/MacOS/Docker --quit-after-install --unattended

doesn't work any more in Docker Desktop 2.1.0.0 (docker v19.03.1). Now you get the error message:

DockerApplication: Docker.app starting for root
Terminator: Running Docker Desktop as root is dangerous. Please run it as a regular user.

Which breaks our CI :( For now, I can download earlier version, but Docker folk... please tell us how to do an unattended installation!

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle locked

@docker docker locked and limited conversation to collaborators Jun 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants