Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task won't start with volumesFrom defined, agent doesn't say why #756

Closed
JunkMyFunk opened this issue Apr 6, 2017 · 5 comments
Closed

Comments

@JunkMyFunk
Copy link

I have a basic task defined with 2 containers - an nginx container site linked to a php-fpm container site-php. The php-fpm container needs to access the website files on the nginx container so I'm trying to use volumesFrom to do this.

Task definition is:

{
    "family": "website",
    "networkMode": "bridge",
    "containerDefinitions": [{
        "name": "site",
        "memoryReservation": 500,
        "portMappings": [{
            "containerPort": 80,
            "hostPort": 80
        }, {
            "containerPort": 443,
            "hostPort": 443
        }],
        "essential": true,
        "links": ["site-php:site-php"],
        "image": "372423516982.dkr.ecr.eu-west-2.amazonaws.com/site/www:latest"
    }, {
        "name": "site-php",
        "volumesFrom": [{
            "sourceContainer": "site"
        }],
        "memoryReservation": 1000,
        "image": "372423516982.dkr.ecr.eu-west-2.amazonaws.com/site/www-php:latest"
    }]
}

The Dockerfile for site has the line VOLUME /var/www/html which I'm expecting the site-php container to mount. The exact same task definition with the volumesFrom section removed from site-php starts up fine (although the website obviously doesn't work I can still get a response from nginx) and the docker-compose equivalent of this run locally works too.

When I run the task with volumesFrom defined this way it stops immediately, the agent logs the following but no containers are started and there're no other logs available to work out what the problem might be. The AWS interface just says Stopped reason: Essential container in task exited with no further information.

2017-04-06T11:45:20Z [CRITICAL] Task in a bad state; it's not steadystate but no containers want to transition module="TaskEngine" task="site-only:4 arn:aws:ecs:eu-west-2:372423516982:task/c9ce3c1d-97b2-4656-96da-a576059403d1, Status: (NONE->RUNNING) Containers: [site (NONE->RUNNING),site-php (NONE->RUNNING),]"
2017-04-06T11:45:20Z [CRITICAL] Moving task to stopped due to bad state module="TaskEngine" task="site-only:4 arn:aws:ecs:eu-west-2:372423516982:task/c9ce3c1d-97b2-4656-96da-a576059403d1, Status: (NONE->RUNNING) Containers: [site (NONE->RUNNING),site-php (NONE->RUNNING),]"

Is there something obvious wrong with this task definition? If not, how can I get better error messages to work out what the problem is?

@richardpen
Copy link

@JunkMyFunk Looks like there is a conflict in your task definition in terms of the dependency:
links requires the site-php container to be launched before site container, while the volumesFrom require the site container to be launched before site-php. That's why the task can't be transitioned as shown in the error message.

What's the reason you want to use links here, if you just want the site-php container to use the volume from site, you can simply delete the "links": ["site-php:site-php"], in your task definition.

Thanks,
Richard

@JunkMyFunk
Copy link
Author

Yup, you're right - well spotted. Not sure why links is there as I don't have that in my local docker-compose.

So trying this configuration locally with docker produces ERROR: Circular dependency between site-php and site... just the kind of descriptive error I could have done with from the agent.

Thanks though @richardpen

@JunkMyFunk
Copy link
Author

I remember why I needed links - locally I can setup the network API rather than use the deprecated links feature. Which means I need #437 to get this configuration to work

@richardpen
Copy link

@JunkMyFunk Thanks for pointing this out, we should improve the error message in the agent to be more descriptive. I'll keep this issue open until it is fixed, for the user defined network feature please track #437 for any updates.

Thanks,
Richard

@aaithal
Copy link
Contributor

aaithal commented Jan 29, 2018

Hi @richardpen @JunkMyFunk , since we last updated this issues, we have released Task networking for ECS, which should provide a better model for two containers in a task to communicate with each other (over localhost). We have also updated our task definition registration logic to detect circular dependencies. Since user defined networking is already captured in #437, i'm going to resolve this for now. Please feel free to create a new issue if you have more questions/comments. Thanks!

@aaithal aaithal closed this as completed Jan 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants