41

who has ever tried following this tutorial about Docker Swarm?

https://docs.docker.com/get-started/part4/

There is a section called : Create a cluster. What I wanted to do was to create a couple of VMs using docker-machine. Since I use ubuntu16.0.4 so I used following commands to get VirtualBox.

sudo apt-get update
sudo apt-get install virtualbox-5.2

After I installed VirtualBox, typed a command like :

docker-machine create --driver virtualbox myvm1

But it says : sudo: docker-machine: command not found

So I typed another command to check if I have installed VirtualBox correctly.

sudo virtualbox version

This opens the Oracle VM VirtualBox Manager, which means I did install VirtualBox correctly , but not sure.

Could anyone help me with a proper solution? Any help would be appreciated.

coturiv
  • 2,880
  • 22
  • 39
CHRIS LEE
  • 776
  • 3
  • 10
  • 20
  • 2
    Have you installed docker-machine as per https://docs.docker.com/machine/install-machine/ ? In the prerequisites it states that you must have Docker machine installed and that on Linux it does not come pre-installed – twoTimesAgnew Nov 15 '17 at 07:16
  • No,I haven't. Let me try to install docker-machine as per docs.docker.com/machine/install-machine – CHRIS LEE Nov 15 '17 at 12:26

5 Answers5

61

You need to install Docker Machine first on your local machine. If you use Ubuntu, just use this snippet (Update the version from the Official Repository Releases if needed) :

$ curl -L https://github.com/docker/machine/releases/download/v0.16.0/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine &&
chmod +x /tmp/docker-machine &&
sudo cp /tmp/docker-machine /usr/local/bin/docker-machine
msangel
  • 9,895
  • 3
  • 50
  • 69
coturiv
  • 2,880
  • 22
  • 39
  • 1
    I used this inside my virtualbox, but it didn't work. The binary gets created with "Not Found" string inside it. – l0k3ndr Dec 28 '17 at 12:14
  • This answers installs an outdated version of Docker Machine. [I've added an answer with links to up to date instructions and the releases page on GitHub](https://stackoverflow.com/a/50770461/8015265). – DaveLak Jun 09 '18 at 02:45
33

The accepted answer contains outdated install instructions!

Up to date instructions for Docker Machine can be found in the official documentation here. This includes instructions for MacOS, Linux (including Ubuntu) & Windows with Git BASH. Full documentation can be found here.

While @sdey0081's answer is more or less correct, running the posted commands will result in an outdated version of Docker Machine being installed. The version it installs is v0.13.0 while the current release at the time of writing is v0.15.0. You can find the available releases in the GitHub repo here.

Community
  • 1
  • 1
DaveLak
  • 796
  • 9
  • 19
  • 1
    This one is the real answer referring to the official documentation is just right. – Shift 'n Tab Jun 27 '18 at 11:10
  • 3
    This is the correct answer, for sure. Still I have to say that I'm a bit troubled by how comfortable people are expected to be with downloading and running binaries on Linux systems, these days. – Teekin Jul 07 '18 at 11:50
  • The big difference is that according to docs, you have to install docker on your machine. That will increase overhead significantly just to use docker-machine. – Croll Apr 05 '19 at 17:53
5

On MacOS installing with brew is the simplest solution: brew install docker-machine

Unknown_Guy
  • 948
  • 9
  • 17
1

Just additional information with steps to the main answer:

1) To install docker-machine you need to write this as mantioned @coturiv:

$ curl -L https://github.com/docker/machine/releases/download/v0.16.1/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine &&
    chmod +x /tmp/docker-machine &&
    sudo cp /tmp/docker-machine /usr/local/bin/docker-machine

2) If you get the error after running the command docker-machine create:

Error creating machine: Error with pre-create check: VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path

be sure that you also installed virtualbox:

sudo apt-get install virtualbox

3) If you get again the error like:

This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory 

try to run the command docker-machine create using --virtualbox-no-vtx-check like:

docker-machine create default --virtualbox-no-vtx-check
invzbl3
  • 5,872
  • 9
  • 36
  • 76
  • this answer suffers the same issue of recommending an outdated version – DaveLak Apr 17 '20 at 03:20
  • @DaveLak that's why I wrote as additional information to the main answer. It can be helpful if you reproduce these issues and want to understand/analyze why it happens to you while trying to solve the main problem, but also you can improve it if you know how. – invzbl3 Apr 17 '20 at 22:41
0

https://docs.docker.com/machine/ :

Docker Machine has been deprecated. Please use Docker Desktop instead. See Docker Desktop for Mac and Docker Desktop for Windows. You can also use other cloud provisioning tools.

Pawel W
  • 101
  • 1
  • 1
  • 12