Reputation: 3080
I want to add multiple volume defintions in my ECS task definition JSON like this:
[
{
"name": "agent",
"image": "${agent_image}",
"essential": true,
"environment": [
{
"name": "apple",
"value": "mango"
},
{
"name": "AGENT_NAME",
"value": "AGENT3"
}
],
"volume": {
"name" : "/data/agent2/conf",
"host_path" : "/data/agent2/conf"
}
"volume": {
"name" : "/data/agent3/conf",
"host_path" : "/data/agent3/conf"
}
}
]
This is obviously not working because json cannot have 2 keys volume
with the same name. How to acheive this? Please help.
Upvotes: 1
Views: 2431
Reputation: 672
I don't know exactly what you are trying to achieve, but let me try to help with a few ideas:
The following will map the /data/agent3/conf
to the /data/agent/conf
inside your container:
{
"containerDefinitions": [
{
"mountPoints": [
{
"containerPath": "/data/agent/conf",
"sourceVolume": "vol1"
}
]
}
],
"volumes": [
{
"name": "vol1",
"host": {
"sourcePath": "/data/agent3/conf"
}
}
]
}
If you want to use two volumes:
{
"containerDefinitions": [
{
"mountPoints": [
{
"containerPath": "/data/agent/conf",
"sourceVolume": "vol1"
},
{
"containerPath": "/alternate/path/to/conf",
"sourceVolume": "vol2"
}
]
}
],
"volumes": [
{
"name": "vol1",
"host": {
"sourcePath": "/data/agent3/conf"
}
},
{
"name": "vol2",
"host": {
"sourcePath": "/data/agent3/conf"
}
}
]
}
As far as I know, It's not possible to mount two volumes into the same mount point within your container. :)
But if you're trying to share data between containers/tasks between multiple hosts, Amazon EFS will be a better option.
You can find more details bellow:
Amazon ECS and Docker volume drivers
Upvotes: 2