Docker-machine create machine on Cloud (DigitalOcean)

admin/ July 18, 2017/ Docker/ 0 comments

Docker-machine create machine on Cloud (DigitalOcean)

Docker-machine allows you to manage the docker machines (VMs) using your local system weather VMs on AWS, Digitalocean, etc.

Here, I am going to tell you how to create the docker machine on digitalocean.

Step1-: Install the docker-machine in your local system using below command.

$ curl -L https://github.com/docker/machine/releases/download/v0.12.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

Step 2-: Generate the digitalocean api token to access the digitalocean account using the docker-machine.

a) Login the https://cloud.digitalocean.com/login

b) Click on the “API” tab on the menu bar

c) Click on the “Generate New Token” button on the right.

Step 3-: Use the below command to create the docker-machine.

docker-machine create --driver digitalocean --digitalocean-access-token "digitalocean token" docker-sandbox

Note-: Paste the digitalocean token where the double quote without double quote and make sure the you have enabled the Port 2376 on your localsystem or Server.

Output-:

Creating CA: /root/.docker/machine/certs/ca.pem
Creating client certificate: /root/.docker/machine/certs/cert.pem
Running pre-create checks...
Creating machine...
(docker-sandbox) Creating SSH key...
(docker-sandbox) Creating Digital Ocean droplet...
(docker-sandbox) Waiting for IP address to be assigned to the Droplet...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with ubuntu(systemd)...
Installing Docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...

Step 4-: Setup the docker environment using below command-:

$ docker-machine env docker-sandbox
$ eval $(docker-machine env docker-sandbox)

Now you have successfully created the docker-machine on the digitalocean cloud.

To check the docker machine. use docker-machine ls command.

$ docker-machine ls

Output-:

NAME             ACTIVE   DRIVER         STATE     URL                         SWARM   DOCKER        ERRORS
docker-sandbox   *        digitalocean   Running   tcp://104.131.40.222:2376           v17.06.0-ce

To connect the docker machine using docker-machine command.

$ docker-machine ssh docker-sandbox

Use the docker-machine name in place of docker-sandbox

Leave a Reply