Change the default port of mongodb on ECS Instance - mongodb

EDIT : I finally resolved my problem, I replace the command line by :
"command": [
"mongod",
"--port",
"3001"
]
I want to run mongodb on port 3001 instead of 27017 on my ECS instance. I have one application (annonces) and one database (mongodb).
This is my Task Definition configuration :
{
"executionRoleArn": null,
"containerDefinitions": [
{
"dnsSearchDomains": null,
"logConfiguration": null,
"entryPoint": null,
"portMappings": [
{
"hostPort": 80,
"protocol": "tcp",
"containerPort": 4001
}
],
"command": null,
"linuxParameters": null,
"cpu": 0,
"environment": [
{
"name": "DB_URI",
"value": "mongodb://mongo:3001/db-annonces"
}
],
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"dockerSecurityOptions": null,
"memory": 128,
"memoryReservation": null,
"volumesFrom": [],
"image": "XXXXXXXXXXX.dkr.ecr.eu-west-3.amazonaws.com/annonces-service:latest",
"disableNetworking": null,
"healthCheck": null,
"essential": true,
"links": [
"mongo"
],
"hostname": null,
"extraHosts": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": null,
"privileged": null,
"name": "annonces"
},
{
"dnsSearchDomains": null,
"logConfiguration": null,
"entryPoint": [],
"portMappings": [
{
"hostPort": 3001,
"protocol": "tcp",
"containerPort": 3001
}
],
"command": [
"mongod --port 3001"
],
"linuxParameters": null,
"cpu": 0,
"environment": [],
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"dockerSecurityOptions": null,
"memory": 128,
"memoryReservation": null,
"volumesFrom": [],
"image": "mongo:latest",
"disableNetworking": null,
"healthCheck": null,
"essential": false,
"links": null,
"hostname": "mongo",
"extraHosts": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": null,
"privileged": null,
"name": "mongo"
}
],
"placementConstraints": [],
"memory": null,
"taskRoleArn": null,
"compatibilities": [
"EC2"
],
"taskDefinitionArn": "arn:aws:ecs:eu-west-3:XXXXXXXX:task-definition/annonces-task:17",
"family": "annonces-task",
"requiresAttributes": [
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.17"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.ecr-auth"
}
],
"requiresCompatibilities": null,
"networkMode": "bridge",
"cpu": null,
"revision": 17,
"status": "ACTIVE",
"volumes": []
}
The problem seems to come from the line :
"command": [
"mongod --port 3001"
]
When I try to run the task, the task shut down immediately. If I remove this line, it works but the database is not on port 3001.
If i run the command docker logs on the specific container, I get the following error :
/usr/local/bin/docker-entrypoint.sh: line 340: exec: mongod --port 3001: not found

Related

AWS ECS Fargate Logging: Facing issue with Firelens side-car container approach to push log files present inside application container to Cloudwatch

I want to push log files which are present in a specific folder inside a container to Cloudwatch. For this, I tried Firelens logdriver but had no luck.
As mentioned here : https://github.com/aws-samples/amazon-ecs-firelens-examples/tree/mainline/examples/fluent-bit/config-file-type-file
I created a custom docker image for fluentbit and deployed it as a side car container in task definition:
FROM public.ecr.aws/aws-observability/aws-for-fluent-bit:stable
COPY fluentbit.conf /extra.conf
fluentbit.conf (I tried exec for debugging purpose, aim is to use tail):
[INPUT]
Name exec
Tag exec_ls
Command ls /opt/apache-tomcat-8.5.72/my-app/logs
Interval_Sec 3
Interval_NSec 0
Buf_Size 8mb
[OUTPUT]
Name cloudwatch
Match *
region ap-south-1
log_group_name fluent-bit-adapter-logs
log_stream_prefix from-fluent-bit-
auto_create_group true
log_key log
This is my ECS Fargate task definition :
{
"ipcMode": null,
"executionRoleArn": "<role>",
"containerDefinitions": [
{
"dnsSearchDomains": null,
"environmentFiles": null,
"logConfiguration": {
"logDriver": "awsfirelens",
"secretOptions": null,
"options": {
"log_group_name": "/aws/ecs/containerinsights/$(ecs_cluster)/application",
"auto_create_group": "true",
"log_key": "log",
"log_stream_prefix": "log_stream_name",
"region": "ap-south-1",
"Name": "cloudwatch"
}
},
"entryPoint": null,
"portMappings": [
{
"hostPort": 8080,
"protocol": "tcp",
"containerPort": 8080
}
],
"command": null,
"linuxParameters": null,
"cpu": 0,
"environment": [],
"resourceRequirements": null,
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"secrets": null,
"dockerSecurityOptions": null,
"memory": null,
"memoryReservation": null,
"volumesFrom": [],
"stopTimeout": null,
"image": "<image-url>",
"startTimeout": null,
"firelensConfiguration": null,
"dependsOn": null,
"disableNetworking": null,
"interactive": null,
"healthCheck": null,
"essential": true,
"links": null,
"hostname": null,
"extraHosts": null,
"pseudoTerminal": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": null,
"systemControls": null,
"privileged": null,
"name": "my-app"
},
{
"dnsSearchDomains": null,
"environmentFiles": null,
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": null,
"options": {
"awslogs-group": "/ecs/log_router",
"awslogs-region": "ap-south-1",
"awslogs-create-group": "true",
"awslogs-stream-prefix": "firelens"
}
},
"entryPoint": null,
"portMappings": [],
"command": null,
"linuxParameters": null,
"cpu": 0,
"environment": [],
"resourceRequirements": null,
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"secrets": null,
"dockerSecurityOptions": null,
"memory": null,
"memoryReservation": 50,
"volumesFrom": [],
"stopTimeout": null,
"image": "<image-url>",
"startTimeout": null,
"firelensConfiguration": {
"type": "fluentbit",
"options": {
"config-file-type": "file",
"config-file-value": "/extra.conf"
}
},
"dependsOn": null,
"disableNetworking": null,
"interactive": null,
"healthCheck": null,
"essential": true,
"links": null,
"hostname": null,
"extraHosts": null,
"pseudoTerminal": null,
"user": "0",
"readonlyRootFilesystem": null,
"dockerLabels": null,
"systemControls": null,
"privileged": null,
"name": "log_router"
}
],
"placementConstraints": [],
"memory": "8192",
"taskRoleArn": "<role>",
"compatibilities": [
"EC2",
"FARGATE"
],
"taskDefinitionArn": "<my-app arn>",
"family": "equbemi",
"requiresAttributes": [
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.execution-role-awslogs"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.ecr-auth"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.firelens.options.config.file"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.17"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.21"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.logging-driver.awsfirelens"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.task-iam-role"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.execution-role-ecr-pull"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.task-eni"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.29"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.firelens.fluentbit"
}
],
"pidMode": null,
"requiresCompatibilities": [
"FARGATE"
],
"networkMode": "awsvpc",
"cpu": "4096",
"revision": 19,
"status": "ACTIVE",
"inferenceAccelerators": null,
"proxyConfiguration": null,
"volumes": []
}
For my application container, I've given logconfiguration as firelens and deployed a side-car container as mentioned in documentation. I tried the tail command in firelens config but didn't work. So just to troubleshoot, I tried exec and found out in firelens container logs that it is giving "File not found" exception. I assume it is trying to find the path in its own container(the side-car one) and not in the application container. I'm not sure how to make the firelens container access the application container. Am I missing anything here?
*
Here, the problem is that the fluent-bit container does not have access to the application container file system. You need to configure a volume so that the log path will be shared between both of these containers.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_data_volumes.html
Add a volume at the parent level and add this volume as a mount point in both of the container definitions:
{
...
"volumes": [
{
"fsxWindowsFileServerVolumeConfiguration": null,
"efsVolumeConfiguration": null,
"name": "log_path",
"host": {
"sourcePath": null
},
"dockerVolumeConfiguration": null
}
],
...
"containerDefinitions": [
{
...
"mountPoints": [
{
"readOnly": null,
"containerPath": "/var/log",
"sourceVolume": "log_path"
}
],
...
},
{
...
"mountPoints": [
{
"readOnly": null,
"containerPath": "/var/log",
"sourceVolume": "log_path"
}
],
...
}
]
...
}

Post grafana dashboard to particular folder

I am trying to use the grafana API to post dashboards to a specific folder. Using the following command, I can see the folder ID's for all folders in my grafana:
curl -X GET http://<username>:<password>#localhost:3000/api/folders?limit=200
[{"id":9,"uid":"6m0M3AZZk","title":"Apps"},{"id":38,"uid":"jEJ5aSVZz","title":"Cluster_Health"},{"id":31,"uid":"vsmJ2dGZz","title":"CPU by App"},{"id":51,"uid":"Fx9ajQXWz","title":"Data Pipeline"},{"id":6,"uid":"dYFMMhZWz","title":"home"},{"id":19,"uid":"qDwG6yWZz","title":"Node_Health"},{"id":18,"uid":"37pWeyWZk","title":"Pending_Data"},{"id":44,"uid":"nreWbxfWz","title":"Prod"},{"id":13,"uid":"PYzEBYZWk","title":"Services"},{"id":27,"uid":"byVe4IMWk","title":"API"}]
Now, I would like to post a dashboard to my Services folder (id 13). However, when I make my request, this dashboard is always going to the General folder. I am using a python script to make my request:
def post_dashboard(filepath):
with open(filepath, "r") as fin:
data = json.loads(fin.read())
data = json.dumps(data)
response = requests.post("http://localhost:3000/api/dashboards/db", headers=headers_raw, data=data)
print(response.json())
print(response.status_code)
My JSON file looks like this:
{"dashboard": {
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": null,
"iteration": 1593098750052,
"links": [],
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Prometheus-1",
"description": "The amount of CPU taken up by redis from top command",
"fill": 0,
"gridPos": {
"h": 8,
"w": 24,
"x": 0,
"y": 0
},
"id": 10,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "app_cpu{node_type=\"process\", cluster_id=~\"$cluster\", app_name=~\".*redisserver.*\"}",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{ host_name }}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "CPU Used",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Prometheus-1",
"description": "The current amount of memory redis is consuming",
"fill": 0,
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 8
},
"id": 2,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "redis_mem_used{cluster_id=~\"$cluster\"}",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{ node }}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Redis Memory Used",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "decbytes",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Prometheus-1",
"description": "The maximum amount of memory that redis has used",
"fill": 0,
"gridPos": {
"h": 9,
"w": 12,
"x": 12,
"y": 8
},
"id": 4,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "redis_mem_peak{cluster_id=~\"$cluster\"}",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{ node }}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Redis Peak Memory",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "decbytes",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Prometheus-1",
"description": "The amount of memory used by the LUA engine inside of redis",
"fill": 0,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 17
},
"id": 6,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "redis_mem_lua{cluster_id=~\"$cluster\"}",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{ node }}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "LUA Mem Used",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "decbytes",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Prometheus-1",
"description": "The amount of memory used as observed by top",
"fill": 0,
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 17
},
"id": 8,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "redis_mem_rss{cluster_id=~\"$cluster\"}",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{ node }}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "RSS Mem Used",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "decbytes",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
}
],
"schemaVersion": 18,
"style": "dark",
"tags": [],
"templating": {
"list": [
{
"allValue": null,
"current": {},
"datasource": "Prometheus-1",
"definition": "label_values(redis_mem_used, cluster_id)",
"hide": 0,
"includeAll": true,
"label": null,
"multi": true,
"name": "cluster",
"options": [],
"query": "label_values(redis_mem_used, cluster_id)",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "",
"title": "Redis",
"uid": "rfdsk32",
"folder": "Services",
"folderTitle": "Services",
"folderId": 13,
"overwrite": true
}
}
My grafana version is 6.2.0. I have used several references that say that folderId should be the controlling keyword for which folder a dashboard goes to.
https://grafana.com/docs/grafana/latest/http_api/dashboard/#create-update-dashboard
You have used wrong payload structure:
{
"dashboard": {
...
"folderId": 13,
"overwrite": true
}
}
Correct structure is:
{
"dashboard": {
...
},
"folderId": 13,
"overwrite": true
}

How to configure a web application running in a docker container to succesfully connect to a MongoDB database running in a different container

Summary of the problem
I have two containers running in Docker on a Synology Diskstation 918+. One container hosts a web application, the other the database. The web application is failing to connect to the database.
Container1: This is the web application container
Name: glidinglogbook
Build: C#/.Net Core 2.1/MongoDb.Driver 2.10.2 + Angular 6/Typescript/Bootstrap for the front end
External port: 8003
Docker network: glb-network
This container's alias for the mongodb container is glbdb
Container2: This is the MongoDB database server
Name: mongodb
Database to connect to: glidinglogbook
External port: 8005
Docker network: glb-network
The details: The web application in the glidinglogbook container is failing to connect to the MongoDB database. 30 seconds after it attempts to connect, it times out with the following stack trace:
al.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
An unhandled exception has occurred while executing the request.
System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerS
elector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "1", ConnectionMode : "Automatic", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ Cl
usterId : 1, EndPoint : "Unspecified/glbdb:8005" }", EndPoint: "Unspecified/glbdb:8005", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception
occurred while opening a connection to the server. ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: Connection refused 172.17.0.2:8005
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.Sockets.Socket.<>c.<ConnectAsync>b__271_0(IAsyncResult iar)
--- End of stack trace from previous location where exception was thrown ---
at MongoDB.Driver.Core.Connections.TcpStreamFactory.ConnectAsync(Socket socket, EndPoint endPoint, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.TcpStreamFactory.CreateStreamAsync(EndPoint endPoint, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.ServerMonitor.HeartbeatAsync(CancellationToken cancellationToken)", LastUpdateTimestamp: "2020-03-03T10:35:02.6718512Z" }] }.
at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description)
at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask)
at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChanged(IServerSelector selector, ClusterDescription description, Task descriptionChangedTask, TimeSpan timeout, CancellationToken cancellation
Token)
at MongoDB.Driver.Core.Clusters.Cluster.SelectServer(IServerSelector selector, CancellationToken cancellationToken)
at MongoDB.Driver.MongoClient.AreSessionsSupportedAfterServerSelection(CancellationToken cancellationToken)
at MongoDB.Driver.MongoClient.AreSessionsSupported(CancellationToken cancellationToken)
at MongoDB.Driver.OperationExecutor.StartImplicitSession(CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession[TResult](Func`2 func, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](FilterDefinition`1 filter, FindOptions`2 options, CancellationToken cancellationToken)
at MongoDB.Driver.FindFluent`2.ToCursor(CancellationToken cancellationToken)
at MongoDB.Driver.IAsyncCursorSourceExtensions.ToList[TDocument](IAsyncCursorSource`1 source, CancellationToken cancellationToken)
at GlidingLogbook.Repositories.FlightRepository.GetAll() in C:\Users\Dave\source\repos\GlidingLogbook\Repositories\FlightRepository.cs:line 22
at GlidingLogbook.Controllers.FlightsController.GetAll() in C:\Users\Dave\source\repos\GlidingLogbook\Controllers\FlightsController.cs:line 25
My Observations:
The stack trace above includes this: EndPoint : "Unspecified/glbdb:8005" which suggests that I am in some way wrongly identifying the database host. Can anyone tell me what is "unspecified" here?
I have no problems connecting to the MongDB database with Robo3T, using the credentials from my appsettings.json below, other than the hostname needs to be MyServer:8005.
When I run the web application in the Visual Studio 2019 debugger, it connects successfully to the database and performs CRUD operations in the normal way, as long as I change the database server host name to MyServer:8005.
I can browse to http://MyServer:8003 to display the UI, but in the docker context the web application is failing to connect to the database so no data is displayed.
Here is my appsettings.json:
{
"dbUsername": "[redacted]",
"dbPassword": "[redacted]",
"dbAuthMechanism": "SCRAM-SHA-1",
"dbHost": "glbdb",
"dbHostPort": 8005,
"dbName": "glidinglogbook",
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}
And here is the C# code I am using to get a reference to the database:
public class Database : IDatabase
{
private readonly Settings settings;
public Database(IOptionsMonitor<Settings> settings)
{
this.settings = settings.CurrentValue;
}
public IMongoDatabase Get()
{
var internalIdentity = new MongoInternalIdentity("admin", settings.DbUsername);
var passwordEvidence = new PasswordEvidence(settings.DbPassword);
var mongoCredential = new MongoCredential(settings.DbAuthMechanism, internalIdentity, passwordEvidence);
var mongoClientSettings = new MongoClientSettings
{
Credential = mongoCredential,
Server = new MongoServerAddress(settings.DbHost, settings.DbHostPort)
};
var client = new MongoClient(mongoClientSettings);
return client.GetDatabase(settings.DbName);
}
}
In the course of my investigation, I also came up with the following:
docker network inspect glb-network
[
{
"Name": "glb-network",
"Id": "beb299fbdbe1a230891427828a41e804040bd1e5403ecbb9bdff4abb86c47af5",
"Created": "2020-03-02T16:38:49.893845611Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.21.0.0/16",
"Gateway": "172.21.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"9621d3b4971a585a632fb066bcd5b213a8e20f474729e6df20ef1e7ad3304b38": {
"Name": "alpine1",
"EndpointID": "c779c757b4847cd21fcb612e15a23a6d15a03ae4729a12d26a59cece14004e88",
"MacAddress": "02:42:ac:15:00:04",
"IPv4Address": "172.21.0.4/16",
"IPv6Address": ""
},
"b491359c438df68fd247401ede1c9a999f74849f0fa78a4de898ea9c2a50b18a": {
"Name": "glidinglogbook",
"EndpointID": "e6a18ad3e811fddfab904f05a6f95bdd1f4323e727e71e5838d14a7a0e8eecc5",
"MacAddress": "02:42:ac:15:00:03",
"IPv4Address": "172.21.0.3/16",
"IPv6Address": ""
},
"d9e756043c562fd4f8f2e57f114e56a0dd0256ecb72b50b47cf89f3e343fa643": {
"Name": "mongodb",
"EndpointID": "309b739d4a53a95e28e1e1713be100778619d2b74f6f7c6c2abef66dbbc253f0",
"MacAddress": "02:42:ac:15:00:02",
"IPv4Address": "172.21.0.2/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]
and...
docker container inspect glidinglogbook
[
{
"Id": "b491359c438df68fd247401ede1c9a999f74849f0fa78a4de898ea9c2a50b18a",
"Created": "2020-03-03T10:26:34.120702556Z",
"Path": "/bin/sh",
"Args": [
"-c",
"\"dotnet\" \"GlidingLogbook.dll\""
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 18767,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-03-03T10:32:24.412840804Z",
"FinishedAt": "2020-03-03T10:32:05.106756231Z",
"StartedTs": 1583231544,
"FinishedTs": 1583231525
},
"Image": "sha256:e6f43665ec3bc215de8913af816f88372aee8e8ee88ea16bd0765861f4fe6311",
"ResolvConfPath": "/volume1/#docker/containers/b491359c438df68fd247401ede1c9a999f74849f0fa78a4de898ea9c2a50b18a/resolv.conf",
"HostnamePath": "/volume1/#docker/containers/b491359c438df68fd247401ede1c9a999f74849f0fa78a4de898ea9c2a50b18a/hostname",
"HostsPath": "/volume1/#docker/containers/b491359c438df68fd247401ede1c9a999f74849f0fa78a4de898ea9c2a50b18a/hosts",
"LogPath": "/volume1/#docker/containers/b491359c438df68fd247401ede1c9a999f74849f0fa78a4de898ea9c2a50b18a/log.db",
"Name": "/glidinglogbook",
"RestartCount": 0,
"Driver": "btrfs",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"HostConfig": {
"Binds": [],
"ContainerIDFile": "",
"LogConfig": {
"Type": "db",
"Config": {}
},
"NetworkMode": "bridge",
"PortBindings": {
"64839/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8003"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": [
"/mongodb:/glidinglogbook/glbdb"
],
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"DOTNET_SDK_VERSION=2.1.804",
"ASPNETCORE_URLS=http://*:64839",
"DOTNET_RUNNING_IN_CONTAINER=true",
"DOTNET_USE_POLLING_FILE_WATCHER=true",
"NUGET_XMLDOC_MODE=skip"
],
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 50,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": null,
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": null,
"Name": "btrfs"
},
"Mounts": [],
"Config": {
"Hostname": "glidinglogbook",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"64839/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"DOTNET_SDK_VERSION=2.1.804",
"ASPNETCORE_URLS=http://*:64839",
"DOTNET_RUNNING_IN_CONTAINER=true",
"DOTNET_USE_POLLING_FILE_WATCHER=true",
"NUGET_XMLDOC_MODE=skip"
],
"Cmd": null,
"ArgsEscaped": true,
"Image": "glidinglogbook:latest",
"Volumes": null,
"WorkingDir": "/app",
"Entrypoint": [
"/bin/sh",
"-c",
"\"dotnet\" \"GlidingLogbook.dll\""
],
"OnBuild": null,
"Labels": {},
"DDSM": false
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "3bc8bdb7582c1994d052735054d64b170d90b9e9bf54de3ffbd9635cb828ff45",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"64839/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8003"
}
]
},
"SandboxKey": "/var/run/docker/netns/3bc8bdb7582c",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "9297dc46163c799987c4cb57d5ee3ea8c3855bca3476ca503ecbd760eb5eb8b1",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:03",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "dad2d9a926d79fd266bcf1494a9ca5249666fd0280d799eb3b9589f9e7e7d750",
"EndpointID": "9297dc46163c799987c4cb57d5ee3ea8c3855bca3476ca503ecbd760eb5eb8b1",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:03",
"DriverOpts": null
},
"glb-network": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"b491359c438d"
],
"NetworkID": "beb299fbdbe1a230891427828a41e804040bd1e5403ecbb9bdff4abb86c47af5",
"EndpointID": "e6a18ad3e811fddfab904f05a6f95bdd1f4323e727e71e5838d14a7a0e8eecc5",
"Gateway": "172.21.0.1",
"IPAddress": "172.21.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:15:00:03",
"DriverOpts": null
}
}
}
}
]
...and finally...
docker container inspect mongodb
[
{
"Id": "d9e756043c562fd4f8f2e57f114e56a0dd0256ecb72b50b47cf89f3e343fa643",
"Created": "2020-02-26T15:42:39.938818193Z",
"Path": "docker-entrypoint.sh",
"Args": [
"mongod"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 17093,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-03-03T10:30:42.368424228Z",
"FinishedAt": "2020-03-03T10:29:59.821302747Z",
"StartedTs": 1583231442,
"FinishedTs": 1583231399
},
"Image": "sha256:bcef5fd2979dbcbf76e46139680bf71c35925e344afa4703de43bdc44c6c526a",
"ResolvConfPath": "/volume1/#docker/containers/d9e756043c562fd4f8f2e57f114e56a0dd0256ecb72b50b47cf89f3e343fa643/resolv.conf",
"HostnamePath": "/volume1/#docker/containers/d9e756043c562fd4f8f2e57f114e56a0dd0256ecb72b50b47cf89f3e343fa643/hostname",
"HostsPath": "/volume1/#docker/containers/d9e756043c562fd4f8f2e57f114e56a0dd0256ecb72b50b47cf89f3e343fa643/hosts",
"LogPath": "/volume1/#docker/containers/d9e756043c562fd4f8f2e57f114e56a0dd0256ecb72b50b47cf89f3e343fa643/log.db",
"Name": "/mongodb",
"RestartCount": 0,
"Driver": "btrfs",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/volume1/docker/mongodb:/data/db:rw"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "db",
"Config": {}
},
"NetworkMode": "bridge",
"PortBindings": {
"27017/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8005"
}
]
},
"RestartPolicy": {
"Name": "always",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.11",
"JSYAML_VERSION=3.13.0",
"GPG_KEYS=E162F504A20CDF15827F718D4B7C549A058F8B6B",
"MONGO_PACKAGE=mongodb-org",
"MONGO_REPO=repo.mongodb.org",
"MONGO_MAJOR=4.2",
"MONGO_VERSION=4.2.3",
"MONGO_INITDB_ROOT_PASSWORD=p*FW~t",
"MONGO_INITDB_ROOT_USERNAME=mongodbuser"
],
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 50,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": null,
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": null,
"Name": "btrfs"
},
"Mounts": [
{
"Type": "volume",
"Name": "e4a576d00714481bcb576441551dc24c569f9e6b6ed6b9b48d2742c4e2baddb5",
"Source": "/volume1/#docker/volumes/e4a576d00714481bcb576441551dc24c569f9e6b6ed6b9b48d2742c4e2baddb5/_data",
"Destination": "/data/configdb",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
},
{
"Type": "bind",
"Source": "/volume1/docker/mongodb",
"Destination": "/data/db",
"Mode": "rw",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "mongodb",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"27017/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.11",
"JSYAML_VERSION=3.13.0",
"GPG_KEYS=E162F504A20CDF15827F718D4B7C549A058F8B6B",
"MONGO_PACKAGE=mongodb-org",
"MONGO_REPO=repo.mongodb.org",
"MONGO_MAJOR=4.2",
"MONGO_VERSION=4.2.3",
"MONGO_INITDB_ROOT_PASSWORD=p*FW~t",
"MONGO_INITDB_ROOT_USERNAME=mongodbuser"
],
"Cmd": [
"mongod"
],
"ArgsEscaped": true,
"Image": "mongo:latest",
"Volumes": {
"/data/configdb": {},
"/data/db": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {},
"DDSM": false
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "ca8ed91e9dabe029ef61412f4e0d385ddbfe5ca010fb7d4a933b441b5dcba5df",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"27017/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8005"
}
]
},
"SandboxKey": "/var/run/docker/netns/ca8ed91e9dab",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "2d4ae043a660b10324570e621c3fdf13043d334c5a511c77252411a360b99539",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "dad2d9a926d79fd266bcf1494a9ca5249666fd0280d799eb3b9589f9e7e7d750",
"EndpointID": "2d4ae043a660b10324570e621c3fdf13043d334c5a511c77252411a360b99539",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
},
"glb-network": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"d9e756043c56"
],
"NetworkID": "beb299fbdbe1a230891427828a41e804040bd1e5403ecbb9bdff4abb86c47af5",
"EndpointID": "309b739d4a53a95e28e1e1713be100778619d2b74f6f7c6c2abef66dbbc253f0",
"Gateway": "172.21.0.1",
"IPAddress": "172.21.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:15:00:02",
"DriverOpts": null
}
}
}
}
]
As a Docker newbie, I have pretty much run out of ideas as to why my web application, running in a container, is failing to connect to the database, running in a different container. My observations above about the stack trace may be a clue, but as yet I have't found a configuration that works, although I've tried various different options, including referencing the database by its IP address - nothing worked.
Any help in solving this would be much appreciated!
You can use the mongodb container IP: 172.21.0.2.
If you wish to reach the container using names instead of IP you can use Docker Compose to configure your containers.
Did you inspect if your web application is connected to the same network your database server is in?
https://docs.docker.com/engine/reference/commandline/network_connect/ -> This might help!
Problem solved: the IP address of the MongoDB container was being blocked by the firewall. I added a new rule to allow that IP address through the firewall, and everything suddenly started working.

Publish docker container port and access that port from another docker container

I'm trying to run a postgres container with docker and access to it from another container.
Steps to reproduce:
Run postgres container and publish port: docker run -e POSTGRES_PASSWORD=test -d -p 5555:5432 postgres:9.6
Run other container to access to the postgres:
docker run -it debian /bin/bash
apt-get update
apt-get install telnet
telnet 172.17.0.1 5555
Result: Trying 172.17.0.1... and then fail.
But i can access it from the host with localhost or from outside with the public ip because the image allow all ip, and i am not blocking that port.
The ping works.
I have tested this in my machine and it works as expected, but i need to know why it is not working on this server.
Where can i start looking to know what i have wrong on my server?
Update:
I tried doing the telnet directly to the ip asigned to the postgres container(172.17.0.2) and i get the following error:
telnet 172.17.0.2
Trying 172.17.0.2...
telnet: Unable to connect to remote host: Connection refused
But ping still works at 172.17.0.2
Output of docker inspect on the postgres container:
docker inspect a379130e94f7
[
{
"Id": "a379130e94f7596ebe632e3ae825710c978577a3fb6b245a4f95374051eb8310",
"Created": "2017-03-31T08:07:36.06939775Z",
"Path": "docker-entrypoint.sh",
"Args": [
"postgres"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 20283,
"ExitCode": 0,
"Error": "",
"StartedAt": "2017-03-31T08:07:37.257557864Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:9910dc9f2ac0dbc193abc4718984cb3ad48989fc02cac4b36ad3d6b7d5d781f9",
"ResolvConfPath": "/var/lib/docker/containers/a379130e94f7596ebe632e3ae825710c978577a3fb6b245a4f95374051eb8310/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/a379130e94f7596ebe632e3ae825710c978577a3fb6b245a4f95374051eb8310/hostname",
"HostsPath": "/var/lib/docker/containers/a379130e94f7596ebe632e3ae825710c978577a3fb6b245a4f95374051eb8310/hosts",
"LogPath": "/var/lib/docker/containers/a379130e94f7596ebe632e3ae825710c978577a3fb6b245a4f95374051eb8310/a379130e94f7596ebe632e3ae825710c978577a3fb6b245a4f95374051eb8310-json.log",
"Name": "/gallant_thompson",
"RestartCount": 0,
"Driver": "overlay",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"5432/tcp": [
{
"HostIp": "",
"HostPort": "5555"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": -1,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0
},
"GraphDriver": {
"Name": "overlay",
"Data": {
"LowerDir": "/var/lib/docker/overlay/34f43052282b0bcba741b61cb812bc4e05d1d0045820c36781684e2f2f763b41/root",
"MergedDir": "/var/lib/docker/overlay/904ec813189c55332d8cb5ee3dca74e211a0d42a4434f8a90e07b8a05f4d5c5b/merged",
"UpperDir": "/var/lib/docker/overlay/904ec813189c55332d8cb5ee3dca74e211a0d42a4434f8a90e07b8a05f4d5c5b/upper",
"WorkDir": "/var/lib/docker/overlay/904ec813189c55332d8cb5ee3dca74e211a0d42a4434f8a90e07b8a05f4d5c5b/work"
}
},
"Mounts": [
{
"Type": "volume",
"Name": "82dd5d73415e8142eb5bb985a9695f46772328f271ede839cbf55436917ed120",
"Source": "/var/lib/docker/volumes/82dd5d73415e8142eb5bb985a9695f46772328f271ede839cbf55436917ed120/_data",
"Destination": "/var/lib/postgresql/data",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
"Config": {
"Hostname": "a379130e94f7",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"5432/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"POSTGRES_PASSWORD=test",
"PATH=/usr/lib/postgresql/9.6/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.7",
"LANG=en_US.utf8",
"PG_MAJOR=9.6",
"PG_VERSION=9.6.2-1.pgdg80+1",
"PGDATA=/var/lib/postgresql/data"
],
"Cmd": [
"postgres"
],
"ArgsEscaped": true,
"Image": "postgres:9.6",
"Volumes": {
"/var/lib/postgresql/data": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "55c678dffab73ca25857667ddb003751494d32beb917abd1bba4d77f61071d9f",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"5432/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "5555"
}
]
},
"SandboxKey": "/var/run/docker/netns/55c678dffab7",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "a0f845fa572fd6b15fc7c2ba74d3a302eb353e51ddbafb97d81e8858124808d7",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "16d30671a47d90037673ef30843421eaeeeba41028ec204a8fcea13ac8108f6d",
"EndpointID": "a0f845fa572fd6b15fc7c2ba74d3a302eb353e51ddbafb97d81e8858124808d7",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02"
}
}
}
}
]
I followed your steps and for me it is working.
What you could try is inspect the container. First get it's name with:
docker ps
Then inspect the container with:
docker inspect CONTAINER_NAME
In my example it was docker inspect zealous_wright.
Here you can find the IP adress and port of the container, try to use this IP and port. If it's still not working maybe try assigning a port other then 5555. It could be usefull to share this inspect data of the container maybe we can see what's wrong.
UPDATE:
It probally has to do with proxies. I'm using DockerForMac so there were quite some differences but the one standing out was:
"no_proxy=*.local, 169.254/16"
I had this one and you didn't. When I removed this I got the same error as you. I changed this by going to:
Docker preferences -> Proxies -> Use system proxy, instead of No proxy.
Hope this helps!

How to use SoftLayer REST API to create an Auto Scale Group

I'm using this URL to get an existing Auto Scale Group that I want to clone with modifications. It seems to have all the informmation about Service Port, Policies, Resource Triggers, Watches, Actions that I need to have.
https://api.softlayer.com/rest/v3/SoftLayer_Scale_Group/1120061/getObject.json?objectMask=mask[policies[resourceUseTriggers[watches],actions],loadBalancers]
The resulting response is contained in "RESPONSE 1" below.
I then modify the response to "remove the IDs" and then modify it to use as a template to create a new Auto Scale Group and the new request JSON is shown in "REQUEST 1" below.
When I submit "REQUEST 1" to SoftLayer using a POST to
https://api.softlayer.com/rest/v3/SoftLayer_Scale_Group/createObject.json
I get the standard error - "The remote server returned an error: (500) Internal Server Error."
So what am I doing incorrectly here?
== REQUEST 1 ==
{ "parameters": [
{
"virtualGuestMemberTemplate": {
"accountId": 940999,
"domain": "partpic.com",
"hostname": "CaffeServer-test-001",
"maxMemory": 1024,
"postInstallScriptUri": "https://webdev.partpic.com/ppsvc/CaffeStartup.aspx?model=Sample.tar.gz",
"startCpus": 1,
"blockDeviceTemplateGroup": {
"globalIdentifier": "fb2fd46d-713a-4d9b-8de1-d47030adc728"
},
"datacenter": {
"name": "dal06"
},
"hourlyBillingFlag": true
},
"loadBalancers": [{
"healthCheckId": 609283,
"id": 101503,
"port": 32400,
"virtualServerId": 275643
}],
"policies": [{
"name": "ScaleDown",
"resourceUseTriggers": [{
"typeId": 3,
"watches": [{
"algorithm": "EWMA",
"metric": "host.cpu.percent",
"operator": "<",
"period": 1500,
"value": "20"
}]
}],
"actions": [{
"typeId": 1,
"amount": 80,
"scaleType": "PERCENT"
}]
},
{
"name": "ScaleUp",
"resourceUseTriggers": [{
"typeId": 3,
"watches": [{
"algorithm": "EWMA",
"metric": "host.cpu.percent",
"operator": ">",
"period": 600,
"value": "80"
}]
}],
"actions": [{
"typeId": 1,
"amount": 150,
"scaleType": "PERCENT"
}]
}],
"status": {
"id": 1,
"keyName": "ACTIVE",
"name": "Active"
},
"virtualGuestAssets": [],
"virtualGuestMembers": [],
"accountId": 940999,
"cooldown": 60,
"name": "scale_test-001",
"regionalGroupId": 22,
"terminationPolicyId": 1
}
]}
== RESPONSE 1 ==
{
"accountId": 940999,
"balancedTerminationFlag": false,
"cooldown": 60,
"createDate": "2016-08-08T13:19:51-05:00",
"desiredMemberCount": null,
"id": 1120061,
"lastActionDate": "2016-08-12T14:22:51-05:00",
"maximumMemberCount": 0,
"minimumMemberCount": 0,
"modifyDate": "2016-08-12T14:22:57-05:00",
"name": "scale_CaffeServerSample",
"regionalGroupId": 22,
"suspendedFlag": false,
"terminationPolicyId": 1,
"virtualGuestMemberTemplate": {
"accountId": 940999,
"createDate": null,
"dedicatedAccountHostOnlyFlag": null,
"domain": "partpic.com",
"hostname": "CaffeServerSample",
"id": null,
"lastPowerStateId": null,
"lastVerifiedDate": null,
"maxCpu": null,
"maxMemory": 1024,
"metricPollDate": null,
"modifyDate": null,
"postInstallScriptUri": "https:\/\/webdev.partpic.com\/ppsvc\/CaffeStartup.aspx?model=Sample.tar.gz",
"provisionDate": null,
"startCpus": 1,
"statusId": null,
"blockDeviceTemplateGroup": {
"accountId": null,
"createDate": null,
"id": null,
"parentId": null,
"publicFlag": null,
"statusId": null,
"transactionId": null,
"userRecordId": null,
"globalIdentifier": "fb2fd46d-713a-4d9b-8de1-d47030adc728"
},
"datacenter": {
"id": null,
"name": "dal06",
"statusId": null
},
"hourlyBillingFlag": true,
"localDiskFlag": false,
"privateNetworkOnlyFlag": false
},
"loadBalancers": [{
"createDate": "2016-08-12T14:06:07-05:00",
"deleteFlag": null,
"healthCheckId": 609283,
"id": 101503,
"modifyDate": "2016-08-12T14:19:33-05:00",
"port": 32400,
"scaleGroupId": 1120061,
"virtualServerId": 274353,
"scaleGroup": {
"accountId": 940999,
"balancedTerminationFlag": false,
"cooldown": 60,
"createDate": "2016-08-08T13:19:51-05:00",
"desiredMemberCount": null,
"id": 1120061,
"lastActionDate": "2016-08-12T14:22:51-05:00",
"maximumMemberCount": 0,
"minimumMemberCount": 0,
"modifyDate": "2016-08-12T14:22:57-05:00",
"name": "scale_CaffeServerSample",
"regionalGroupId": 22,
"suspendedFlag": false,
"terminationPolicyId": 1,
"virtualGuestMemberTemplate": {
"accountId": 940999,
"createDate": null,
"dedicatedAccountHostOnlyFlag": null,
"domain": "partpic.com",
"hostname": "CaffeServerSample",
"id": null,
"lastPowerStateId": null,
"lastVerifiedDate": null,
"maxCpu": null,
"maxMemory": 1024,
"metricPollDate": null,
"modifyDate": null,
"postInstallScriptUri": "https:\/\/webdev.partpic.com\/ppsvc\/CaffeStartup.aspx?model=Sample.tar.gz",
"provisionDate": null,
"startCpus": 1,
"statusId": null,
"blockDeviceTemplateGroup": {
"accountId": null,
"createDate": null,
"id": null,
"parentId": null,
"publicFlag": null,
"statusId": null,
"transactionId": null,
"userRecordId": null,
"globalIdentifier": "fb2fd46d-713a-4d9b-8de1-d47030adc728"
},
"datacenter": {
"id": null,
"name": "dal06",
"statusId": null
},
"hourlyBillingFlag": true,
"localDiskFlag": false,
"privateNetworkOnlyFlag": false
},
"loadBalancers": null,
"policies": [{
"cooldown": null,
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 174557,
"modifyDate": null,
"name": "ScaleDown",
"scaleGroupId": 1120061,
"actions": [{
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 166457,
"modifyDate": null,
"scalePolicyId": 174557,
"typeId": 1,
"scalePolicy": null,
"amount": 80,
"scaleType": "PERCENT"
}],
"resourceUseTriggers": [{
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 173005,
"modifyDate": null,
"scalePolicyId": 174557,
"typeId": 3,
"scalePolicy": null,
"watches": [{
"algorithm": "EWMA",
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 143505,
"metric": "host.cpu.percent",
"modifyDate": null,
"operator": "<",
"period": 1500,
"scalePolicyTriggerId": 173005,
"value": "20",
"scalePolicyTrigger": null
}]
}],
"scaleGroup": null
},
{
"cooldown": null,
"createDate": "2016-08-12T14:22:51-05:00",
"deleteFlag": null,
"id": 174555,
"modifyDate": null,
"name": "ScaleUp",
"scaleGroupId": 1120061,
"actions": [{
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 166455,
"modifyDate": null,
"scalePolicyId": 174555,
"typeId": 1,
"scalePolicy": null,
"amount": 150,
"scaleType": "PERCENT"
}],
"resourceUseTriggers": [{
"createDate": "2016-08-12T14:22:51-05:00",
"deleteFlag": null,
"id": 173003,
"modifyDate": null,
"scalePolicyId": 174555,
"typeId": 3,
"scalePolicy": null,
"watches": [{
"algorithm": "EWMA",
"createDate": "2016-08-12T14:22:51-05:00",
"deleteFlag": null,
"id": 143503,
"metric": "host.cpu.percent",
"modifyDate": null,
"operator": ">",
"period": 600,
"scalePolicyTriggerId": 173003,
"value": "80",
"scalePolicyTrigger": null
}]
}],
"scaleGroup": null
}],
"status": {
"id": 1,
"keyName": "ACTIVE",
"name": "Active"
},
"virtualGuestAssets": [],
"virtualGuestMembers": []
}
}],
"policies": [{
"cooldown": null,
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 174557,
"modifyDate": null,
"name": "ScaleDown",
"scaleGroupId": 1120061,
"actions": [{
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 166457,
"modifyDate": null,
"scalePolicyId": 174557,
"typeId": 1,
"scalePolicy": null,
"amount": 80,
"scaleType": "PERCENT"
}],
"resourceUseTriggers": [{
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 173005,
"modifyDate": null,
"scalePolicyId": 174557,
"typeId": 3,
"scalePolicy": null,
"watches": [{
"algorithm": "EWMA",
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 143505,
"metric": "host.cpu.percent",
"modifyDate": null,
"operator": "<",
"period": 1500,
"scalePolicyTriggerId": 173005,
"value": "20",
"scalePolicyTrigger": null
}]
}],
"scaleGroup": {
"accountId": 940999,
"balancedTerminationFlag": false,
"cooldown": 60,
"createDate": "2016-08-08T13:19:51-05:00",
"desiredMemberCount": null,
"id": 1120061,
"lastActionDate": "2016-08-12T14:22:51-05:00",
"maximumMemberCount": 0,
"minimumMemberCount": 0,
"modifyDate": "2016-08-12T14:22:57-05:00",
"name": "scale_CaffeServerSample",
"regionalGroupId": 22,
"suspendedFlag": false,
"terminationPolicyId": 1,
"virtualGuestMemberTemplate": {
"accountId": 940999,
"createDate": null,
"dedicatedAccountHostOnlyFlag": null,
"domain": "partpic.com",
"hostname": "CaffeServerSample",
"id": null,
"lastPowerStateId": null,
"lastVerifiedDate": null,
"maxCpu": null,
"maxMemory": 1024,
"metricPollDate": null,
"modifyDate": null,
"postInstallScriptUri": "https:\/\/webdev.partpic.com\/ppsvc\/CaffeStartup.aspx?model=Sample.tar.gz",
"provisionDate": null,
"startCpus": 1,
"statusId": null,
"blockDeviceTemplateGroup": {
"accountId": null,
"createDate": null,
"id": null,
"parentId": null,
"publicFlag": null,
"statusId": null,
"transactionId": null,
"userRecordId": null,
"globalIdentifier": "fb2fd46d-713a-4d9b-8de1-d47030adc728"
},
"datacenter": {
"id": null,
"name": "dal06",
"statusId": null
},
"hourlyBillingFlag": true,
"localDiskFlag": false,
"privateNetworkOnlyFlag": false
},
"loadBalancers": [{
"createDate": "2016-08-12T14:06:07-05:00",
"deleteFlag": null,
"healthCheckId": 609283,
"id": 101503,
"modifyDate": "2016-08-12T14:19:33-05:00",
"port": 32400,
"scaleGroupId": 1120061,
"virtualServerId": 274353,
"scaleGroup": null
}],
"policies": null,
"status": {
"id": 1,
"keyName": "ACTIVE",
"name": "Active"
},
"virtualGuestAssets": [],
"virtualGuestMembers": []
}
},
{
"cooldown": null,
"createDate": "2016-08-12T14:22:51-05:00",
"deleteFlag": null,
"id": 174555,
"modifyDate": null,
"name": "ScaleUp",
"scaleGroupId": 1120061,
"actions": [{
"createDate": "2016-08-12T14:23:01-05:00",
"deleteFlag": null,
"id": 166455,
"modifyDate": null,
"scalePolicyId": 174555,
"typeId": 1,
"scalePolicy": null,
"amount": 150,
"scaleType": "PERCENT"
}],
"resourceUseTriggers": [{
"createDate": "2016-08-12T14:22:51-05:00",
"deleteFlag": null,
"id": 173003,
"modifyDate": null,
"scalePolicyId": 174555,
"typeId": 3,
"scalePolicy": null,
"watches": [{
"algorithm": "EWMA",
"createDate": "2016-08-12T14:22:51-05:00",
"deleteFlag": null,
"id": 143503,
"metric": "host.cpu.percent",
"modifyDate": null,
"operator": ">",
"period": 600,
"scalePolicyTriggerId": 173003,
"value": "80",
"scalePolicyTrigger": null
}]
}],
"scaleGroup": {
"accountId": 940999,
"balancedTerminationFlag": false,
"cooldown": 60,
"createDate": "2016-08-08T13:19:51-05:00",
"desiredMemberCount": null,
"id": 1120061,
"lastActionDate": "2016-08-12T14:22:51-05:00",
"maximumMemberCount": 0,
"minimumMemberCount": 0,
"modifyDate": "2016-08-12T14:22:57-05:00",
"name": "scale_CaffeServerSample",
"regionalGroupId": 22,
"suspendedFlag": false,
"terminationPolicyId": 1,
"virtualGuestMemberTemplate": {
"accountId": 940999,
"createDate": null,
"dedicatedAccountHostOnlyFlag": null,
"domain": "partpic.com",
"hostname": "CaffeServerSample",
"id": null,
"lastPowerStateId": null,
"lastVerifiedDate": null,
"maxCpu": null,
"maxMemory": 1024,
"metricPollDate": null,
"modifyDate": null,
"postInstallScriptUri": "https:\/\/webdev.partpic.com\/ppsvc\/CaffeStartup.aspx?model=Sample.tar.gz",
"provisionDate": null,
"startCpus": 1,
"statusId": null,
"blockDeviceTemplateGroup": {
"accountId": null,
"createDate": null,
"id": null,
"parentId": null,
"publicFlag": null,
"statusId": null,
"transactionId": null,
"userRecordId": null,
"globalIdentifier": "fb2fd46d-713a-4d9b-8de1-d47030adc728"
},
"datacenter": {
"id": null,
"name": "dal06",
"statusId": null
},
"hourlyBillingFlag": true,
"localDiskFlag": false,
"privateNetworkOnlyFlag": false
},
"loadBalancers": [{
"createDate": "2016-08-12T14:06:07-05:00",
"deleteFlag": null,
"healthCheckId": 609283,
"id": 101503,
"modifyDate": "2016-08-12T14:19:33-05:00",
"port": 32400,
"scaleGroupId": 1120061,
"virtualServerId": 274353,
"scaleGroup": null
}],
"policies": null,
"status": {
"id": 1,
"keyName": "ACTIVE",
"name": "Active"
},
"virtualGuestAssets": [],
"virtualGuestMembers": []
}
}],
"status": {
"id": 1,
"keyName": "ACTIVE",
"name": "Active"
},
"virtualGuestAssets": [],
"virtualGuestMembers": []
}
I do not think that create a new autoscale group is so easy like copy paste and delete some ids.
try this request:
{
"parameters": [
{
"balancedTerminationFlag": false,
"maximumMemberCount": 0,
"minimumMemberCount": 0,
"cooldown": 60,
"name": "scale_test-0012a",
"regionalGroupId": 22,
"suspendedFlag": false,
"terminationPolicyId": 1,
"virtualGuestMemberTemplate": {
"domain": "partpic.com",
"hostname": "CaffeServer-test-001",
"maxMemory": 1024,
"postInstallScriptUri": "https://webdev.partpic.com/ppsvc/CaffeStartup.aspx?model=Sample.tar.gz",
"startCpus": 1,
"blockDeviceTemplateGroup": {
"globalIdentifier": "fb2fd46d-713a-4d9b-8de1-d47030adc728"
},
"datacenter": {
"name": "dal06"
},
"hourlyBillingFlag": true,
"localDiskFlag": false,
"privateNetworkOnlyFlag": false
},
"loadBalancers": [{
"deleteFlag" : false,
"port": 32400,
"virtualServerId": 275643,
"healthCheck": {
"type": {
"keyname": "DEFAULT"
}
}
}],
"policies": [{
"name": "ScaleDown",
"resourceUseTriggers": [{
"watches": [{
"algorithm": "EWMA",
"metric": "host.cpu.percent",
"operator": "<",
"period": 1500,
"value": "20"
}]
}],
"scaleActions": [{
"amount": 80,
"scaleType": "PERCENT"
}]
}, {
"name": "ScaleUp",
"resourceUseTriggers": [{
"typeId": 3,
"watches": [{
"algorithm": "EWMA",
"metric": "host.cpu.percent",
"operator": ">",
"period": 600,
"value": "80"
}]
}],
"scaleActions": [{
"amount": 150,
"scaleType": "PERCENT"
}]
}]
}
]
}