Skip to content

Instantly share code, notes, and snippets.

@jumanjiman
Last active December 26, 2015 05:59
Show Gist options
  • Save jumanjiman/7105042 to your computer and use it in GitHub Desktop.
Save jumanjiman/7105042 to your computer and use it in GitHub Desktop.
start script for coreos EC2 instance to launch a docker container
#!/bin/bash
# 1. Post a shell script at a gist url.
# 2. Paste the URL to the gist in EC2 coreos instance user data as 1st line of user data.
# 3. Launch coreos instance.
#
# For details, see:
# https://github.com/coreos/init/blob/402cc75e0f5f230f0aa9c83947e9c262ee85cb1f/bin/coreos-c10n#L25-37
function log() {
logger -t $0 $@
}
log This is a log message from coreos-c10n.service in multi-user target to prove that script runs
mkdir -p /run/systemd/generator &> /dev/null
cat > /run/systemd/generator/docker-net2ftp.service <<EOF
[Unit]
Description=net2ftp container
Requires=docker.service
[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/usr/bin/docker run -d -p 80:80 jumanjiman/net2ftp
[Install]
WantedBy=multi-user.target
EOF
systemctl start docker-net2ftp.service && log started net2ftp || log failed to start net2ftp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment