Skip to content

Instantly share code, notes, and snippets.

@JasonSwindle
Last active October 7, 2019 00:52
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JasonSwindle/80d5c37a072bb6ddbd7e to your computer and use it in GitHub Desktop.
Save JasonSwindle/80d5c37a072bb6ddbd7e to your computer and use it in GitHub Desktop.
A task definition for ECS using MeltWater's Docker Container and Image clean-up containerized script. Please see https://github.com/meltwater/docker-cleanup for more details on correct usage.
{
"containerDefinitions": [
{
"volumesFrom": null,
"memory": 32,
"extraHosts": null,
"dnsServers": null,
"disableNetworking": true,
"dnsSearchDomains": null,
"portMappings": [],
"hostname": null,
"essential": true,
"entryPoint": null,
"mountPoints": [
{
"containerPath": "/var/run/docker.sock",
"sourceVolume": "docker_socket",
"readOnly": null
},
{
"containerPath": "/var/lib/docker",
"sourceVolume": "docker_data",
"readOnly": null
}
],
"name": "DockerCleanup-Container",
"ulimits": null,
"dockerSecurityOptions": null,
"environment": [
{
"name": "CLEAN_PERIOD",
"value": "**None**"
},
{
"name": "DELAY_TIME",
"value": "**None**"
},
{
"name": "KEEP_IMAGES",
"value": "**None**"
},
{
"name": "KEEP_CONTAINERS",
"value": "**None**"
},
{
"name": "KEEP_CONTAINERS_NAMED",
"value": "**None**"
},
{
"name": "LOOP",
"value": "true"
},
{
"name": "DEBUG",
"value": 0
}
],
"links": null,
"workingDirectory": null,
"readonlyRootFilesystem": true,
"image": "meltwater/docker-cleanup:1.7.1",
"command": null,
"user": null,
"dockerLabels": null,
"logConfiguration": null,
"privileged": null
}
],
"volumes": [
{
"host": {
"sourcePath": "/var/run/docker.sock"
},
"name": "docker_socket"
},
{
"host": {
"sourcePath": "/var/lib/docker"
},
"name": "docker_data"
}
],
"family": "DockerCleanup-Task"
}
@ernestm
Copy link

ernestm commented Apr 27, 2016

Question - in a CloudFormation-created ECS stack, how do you get this to run one per instance? I've tried both running it in user-data and adding it in an upstart script dropped in via ::Init but neither one seems to interact right with when the ecs service is started.

@moredhel
Copy link

@ernestm, a mild hack could be to expose a port that you're not using anywhere else. This would force all containers to be scheduled on distinct EC2 Instances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment