I am trying to append the IP address of a freshly created droplet, into a .env file which the scripts will then copy onto the droplet for one of the applications to use there is a Eval command i can issue before the copy , is there any means to get the IP address and append it to the .env file in the format “url=http://123.456.789.234:5050: 5050 being the port the application needs in its env file and of course no quotes

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi there,

I recently posted an answer on how to get the IP address of a new Droplet when creating the Droplet via the DigitalOcean API, you can take a look at the answer here:

https://www.digitalocean.com/community/questions/create-droplet-via-api-then-get-public-ip-address-and-store-as-a-variable

Hope that this helps!
Regards,
Bobby

  • Hi hi, Bobby, I did see this!! I am using docker-machine and doctl instead of curl to create my droplet as I am a noob and I don’t want to commit my token to the repo! I did figure out a request that would return to the screen: “doctl compute droplet get laminarghost –output json” laminar ghost being my droplet name, spits up a fairly impressive JSON message on my screen, you are the second person to mention jq so I am trying to figure that out this morning. Thank you for your response! AND any other nudges appreciated

    • Hi there,

      No problem at all! Happy to help!

      Yep, jq is pretty handy! If you’ve never used it, I would recommend taking a look at this quick introduction to jq post here!

      Regards,
      Bobby

      • With your help I have pushed through , than you. I saw in another string someone asked how to make sure a job is completed on DO before looking to get the IP address. I see that a split second after the original request the status is NEW and way down at the bottom of the json is a URL that you can curl to check job status. Which changes to completed. I think this could be levered into a method which will dependably also report if there is some failure etc, trying to make a loop in my bash script to test that

        • Hi there,

          Happy to hear that you’ve made some progress. Yes indeed, adding a function that checks the status sounds like a good next step.

          Regards,
          Bobby