-
Notifications
You must be signed in to change notification settings - Fork 35
/
ecs-docker.yml
121 lines (121 loc) · 3.45 KB
/
ecs-docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 在ECS实例上部署Docker环境,开放安全组端口,安装Nginx并创建自定义镜像image001:v1。
en: Deploy a Docker environment on the ECS instance, open security group ports,
install Nginx, and create a custom image named `image001:v1`.
Parameters:
InstanceId:
Type: String
Label:
en: ECS Instance ID
zh-cn: ECS实例ID
Description:
en: Please select a test ECS instance whose operating system is linux.
zh-cn: 请选择操作系统为linux系统的测试ECS实例。
AssociationProperty: ALIYUN::ECS::Instance::InstanceId
AssociationPropertyMetadata:
Status: Running
Resources:
DS_Instances:
Type: DATASOURCE::ECS::Instances
Properties:
InstanceIds:
- Ref: InstanceId
SecurityGroupIngress_22:
Type: ALIYUN::ECS::SecurityGroupIngress
Properties:
SecurityGroupId:
Fn::Jq:
- First
- .[0].SecurityGroupIds[0]
- Fn::GetAtt:
- DS_Instances
- Instances
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
NicType: intranet
PortRange: 22/22
SecurityGroupIngress_80:
Type: ALIYUN::ECS::SecurityGroupIngress
Properties:
SecurityGroupId:
Fn::Jq:
- First
- .[0].SecurityGroupIds[0]
- Fn::GetAtt:
- DS_Instances
- Instances
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
NicType: intranet
PortRange: 80/80
SecurityGroupIngress_8080:
Type: ALIYUN::ECS::SecurityGroupIngress
Properties:
SecurityGroupId:
Fn::Jq:
- First
- .[0].SecurityGroupIds[0]
- Fn::GetAtt:
- DS_Instances
- Instances
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
NicType: intranet
PortRange: 8080/8080
InstallNginx:
Type: ALIYUN::ECS::RunCommand
DependsOn: ModuleInstallDocker
Properties:
InstanceIds:
- Ref: InstanceId
Type: RunShellScript
Sync: true
Timeout: 3600
CommandContent:
Fn::Sub: |-
#!/bin/bash
docker pull registry-vpc.${ALIYUN::Region}.aliyuncs.com/eci_open/nginx:1.15.10
docker tag registry-vpc.${ALIYUN::Region}.aliyuncs.com/eci_open/nginx:1.15.10 nginx:1.15.10
touch Dockerfile
cat > Dockerfile << EOF
FROM nginx:1.15.10
RUN echo '<h1>Welcome, Docker!</h1>' > /usr/share/nginx/html/index.html
EOF
docker build -t image001:v1 .
docker rm -f nginx-test
docker run --name nginx-test -p 8080:80 -d image001:v1
ModuleInstallDocker:
Version: default
Type: 'MODULE::ACS::OOS::Extension'
Properties:
EcsInstanceIds:
- Ref: InstanceId
PackageName: ACS-Extension-DockerCE-1853370294850618
DependsOn:
- SecurityGroupIngress_22
- SecurityGroupIngress_80
- SecurityGroupIngress_8080
Outputs:
DockerUrl:
Description:
en: Docker page.
zh-cn: Docker页面。
Value:
Fn::Sub:
- http://${IP}:8080
- IP:
Fn::Jq:
- First
- if .[0].PublicIpAddress != [] then .[0].PublicIpAddress[0] else .[0].EipAddress.IpAddress
end
- Fn::GetAtt:
- DS_Instances
- Instances
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- InstanceId
TemplateTags:
- acs:document:试用教程:在ECS上部署并使用Docker