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
aws elb create-load-balancer \ | |
--load-balancer-name MyELB \ | |
--listeners Protocol=TCP,LoadBalancerPort=80,InstanceProtocol=TCP,InstancePort=80 \ | |
--subnets subnet-46e6506c subnet-57b8010f \ | |
--scheme internet-facing \ | |
--security-groups sg-aec570d4 | |
aws autoscaling create-launch-configuration \ | |
--launch-configuration-name MyLC \ | |
--key-name virginia \ |
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
#!/bin/bash | |
yum install httpd -y | |
/sbin/chkconfig --levels 235 httpd on | |
service httpd start | |
instanceId=$(curl http://169.254.169.254/latest/meta-data/instance-id) | |
region=$(curl http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{print $4}') | |
echo "<h1>$instanceId</h1>" > /var/www/html/index.html | |
aws ec2 create-tags --resources "$instanceId" --tags Key=Name,Value="PROD-$instanceId" --region "$region" |
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
var AWS = require('aws-sdk'); | |
exports.handler = function(event, context) { | |
var ec2 = new AWS.EC2({region: 'us-east-1'}); | |
ec2.startInstances({InstanceIds : ['i-0114833f8ffc9151c'] },function (err, data) { | |
if (err) console.log(err, err.stack); | |
else console.log(data); | |
context.done(err,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
#!/bin/bash | |
yum install perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https -y | |
curl http://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.1.zip -O | |
unzip CloudWatchMonitoringScripts-1.2.1.zip | |
rm CloudWatchMonitoringScripts-1.2.1.zip |
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
<powershell> | |
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) | |
choco install python -y | |
(new-object net.webclient).DownloadFile('https://s3.amazonaws.com/aws-cli/AWSCLI64.msi','c:\AWSCLI64.msi') | |
msiexec.exe /i 'C:\AWSCLI64.msi' /qn | |
</powershell> |
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
docker build -t <your name>/node . # -t is short for --tag, your name ~ is ~ Tag name, .(dot) is Build context | |
docker build -f Dockerfile -t abhinavkorpal/node . | |
docker run -d -p 8080:3000 abhinavkorpal/node |
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
docker build -f node.dockerfile -t abhinavkorpal/node . | |
docker run -d --name my-mongodb mongo | |
docker run -d -p 3000:3000 --link my-mongodb:mongodb abhinavkorpal/node | |
docker exec (running container id) node dbSeeder.js ## For connecting to mongodb datatbase |
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
docker network ls | |
docker network create --driver bridge isolated_network ## create ~ create custom network, bridge ~ use a bridge network, isolated_network ~ name of the custom network | |
docker network isolated_network | |
docker network inspect isolated_network | |
docker run -d --net=isolated_network --name nodeapp -p 3000:3000 abhinavkorpal/node ## net ~ run container in network, mongodb ~ link to this containe by name |
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
docker-compose build ## build ~ build or rebuild services define in docker-compose.yml | |
docker-compose build mongo ## mongo ~ only build and rebuild mongo service | |
docker-compose up ## up ~ create and start the container | |
docker-compose upm --no-deps node ## no-deps ~ do not create services that node depends on, node ~ rebuild not images and stop, destroy and recreate only node | |
docker-compose down ## take all the container down(stop and remove) | |
docker-compose down --rmi all --volumes ## remove all volumes and images | |
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
cat /var/lib/docker/containers/(container_id) | |
docker inspect (container_id) | grep Pid | |
nsenter -m -u -n -p -i -t (Pid_number) /bin/bash ## -m ~ mount, -u ~ uts, -n ~ network, -p ~ process, -i ~ ipc, -t ~ target | |
ip a | |
docker-enter (container_id) ## for becoming container root | |
docker exec -it (container_id) /bin/bash ## for becoming container root |
OlderNewer