DigitalOcean: How to run Docker command on newly c

2019-07-26 09:24发布

I'm trying to create a new Droplet and then kick off a Docker command via a UserData bash script. I set the user data via the Java API when creating the droplet and observe that the test files and logs I made are created.

newDroplet.setUserData("#!/bin/bash\n" +
            "touch /test.txt;"+
            "docker login --username=myname--password=mypass > /loginlog;"+
            "docker pull mybuild > /pulllog;"+
            "docker run --log-opt max-size=1g --net host --name myserver -t -i mybuild > /runlog;");

loginlog and pulllog both show successful outcomes. However nothing exists in the file runlog.

I can ssh into the droplet and then run the exact same docker command and it runs as expected. Why can't it be run from a userdata script? Why is no output generated?

1条回答
SAY GOODBYE
2楼-- · 2019-07-26 09:46

The problem ended up being the -t flag in the docker run command. Apparently this doesn't work because it isn't a terminal or something like that. Remove the flag and it runs fine.

查看更多
登录 后发表回答