Last active
March 14, 2017 19:28
-
-
Save devries/a6185723d7b71b0bbd6c30ea7362466d to your computer and use it in GitHub Desktop.
Google Container Optimized OS User-data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cloud-config | |
users: | |
- name: cloudservice | |
uid: 2000 | |
write_files: | |
- path: /etc/systemd/system/cloudservice.service | |
parmissions: 0644 | |
owner: root | |
content: | | |
[Unit] | |
Description=Start a simple docker container | |
[Service] | |
Environment="HOME=/home/cloudservice" | |
ExecStartPre=/usr/share/google/dockercfg_update.sh | |
ExecStartPre=-/usr/bin/docker rm -f helloworld | |
ExecStart=/usr/bin/docker run --rm -u 2000 --name helloworld -p 80:8080 gcr.io/single-arcanum-633/hellobottle:latest | |
ExecStop=/usr/bin/docker stop helloworld | |
ExecStopPost=/usr/bin/docker rm helloworld | |
Restart=on-failure | |
RestartSec=5 | |
- path: /etc/systemd/system/iptable-www.service | |
permissions: 0644 | |
owner: root | |
content: | | |
[Unit] | |
Description=Open firewall for docker | |
[Service] | |
Type=oneshot | |
ExecStart=/sbin/iptables -A INPUT -p tcp --dport 80 -j ACCEPT | |
ExecStart=/sbin/iptables -A INPUT -p tcp --dport 443 -j ACCEPT | |
runcmd: | |
- systemctl daemon-reload | |
- systemctl start iptable-www.service | |
- systemctl start cloudservice.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment