By jefftully
Linux box 18.04, starts a droplet using images stored in a DO registry. I am creating the droplet, updating it, then copying all my assets into it ( including my docker-compose.YAML and everything needed to start the app). ( current end goal is to see my API at an address/port. I can’t pull my images out of the registry ( yet ) without installing doctl, authorizing it ( which includes pasting my API key at a prompt ) then logging into the machine, then I can run my docker-compose up, and everything goes as planned. I want to automate the entire process. My root image is alpine, I would rather not install bash, but if it helps this problem go away I will LOL. Any advice is appreciated!!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
There are a few ways that you can acomplish this using environment variables:
If you pass the --access-token flag when configuring auth. The command will run without needing user input:
doctl auth init --access-token $DO_TOKEN
Note that this will print the token to STOUT. So if you are logging the script, you might want to redirect that so your token can not be viewed in logs:
doctl auth init --access-token $DO_TOKEN> /dev/null
You could also write a configuration file containing the token manually:
echo “access-token: $DO_TOKEN” > ~/.config/doctl/config.yaml
The --access-token flag works with all commands, you could just always pass it when using doctl:
doctl compute droplet create
–image ubuntu-20-04-x64
–size s-1vcpu-1gb
–region nyc1
–access-token $DO_TOKEN
example.com
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.