Machine: userdata not working for digitalocean

Created on 13 Apr 2017  路  2Comments  路  Source: docker/machine

How do I get --digitalocean-userdata to work?

For example, I tried to install cowsay using userdata but failed

docker-machine create \
--driver digitalocean \
--digitalocean-image  ubuntu-14-04-x64 \
--digitalocean-access-token <token> \
--digitalocean-size 512mb \
--digitalocean-region nyc1 \
--digitalocean-userdata worker_provision.sh \
--digitalocean-private-networking worker-1 \

where worker_provision.sh is

#cloud-config

runcmd:
    - apt-get install cowsay

After running the create command,

Running pre-create checks...
Creating machine...
(worker-1) Creating SSH key...
(worker-1) Creating Digital Ocean droplet...
(worker-1) 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(upstart)...
Installing Docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env worker-1

But when I run

docker-machine ssh worker-1

followed by


I get the following message

The program 'cowsay' is currently not installed. You can install it by typing:
apt-get install cowsay

I have tried to follow the following guidelines:

https://docs.docker.com/machine/drivers/digital-ocean/#options
https://www.digitalocean.com/company/blog/automating-application-deployments-with-user-data/

Most helpful comment

Is there any interesting log in /var/log/cloud-init-output.log? Also the page you're linking suggests apt-get -y install [package].

All 2 comments

Is there any interesting log in /var/log/cloud-init-output.log? Also the page you're linking suggests apt-get -y install [package].

I realized that my mistake was to place a tab(t) character instead of spaces in front of the hyphen. It works!

` ___________________
< Thank you @bamarni >


    \   ^__^
     \  (oo)\_______
        (__)\       )\/\
            ||----w |
            ||     ||

`

Was this page helpful?
0 / 5 - 0 ratings