Question

Unable to connect to GITHUB during Docker Instance cloud-init

x-post comment from: An Introduction to Droplet Metadata

I’m using the cloud-init to initialize my docker instance. However, I’m finding that I can’t seem to make a network connection to github.com during init.

My script is:

#!/bin/sh

git clone https://github.com/pkimbrel/centos-node-hello.git

cd centos-node-hello

docker build -t centos-node-hello .
docker run -p 80:8080 -d centos-node-hello

During start up, the logs shows:

fatal: unable to access 'https://github.com/pkimbrel/centos-node-hello.git/': Failed to connect to github.com port 443: Connection timed out

Of course, after that everything fails since I didn’t get the code.

Now, if I let the droplet finish it’s startup sequence and log in, I can re-run the script manually and the git clone works just fine. The docker image gets created and starts and my app is running.

It almost appears that the network hasn’t fully set up when the cloud-init executes.


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I attempted twice to replicate this issue but using your cloud-init script exactly as you pasted it on a newly created droplet based on our docker image completed without any issue on both attempts. It is possible that a temporary network issue caused the problem that you saw but your script, as pasted appears to work perfectly.