aws ecr saying Cannot perform an interactive login from a non TTY device after copied cmd from Amazon Container Services
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Amazon Elastic Container Registry (ECR) is a fully managed container image registry service provided by AWS, making it easy for developers to store, manage, and deploy Docker container images. A common issue that users might encounter when interacting with ECR is the error message: "Cannot perform an interactive login from a non TTY device". This typically occurs when attempting to authenticate ECR using certain command-line environments or scripts.
Understanding the Error Message
The error message "Cannot perform an interactive login from a non TTY device" indicates that the authentication process expects an interactive TTY session, but the current environment does not provide one. TTY (TeleTYpewriter) refers to a terminal session that allows interaction with the user, typically seen in common command-line interfaces.
Why Does This Error Occur?
- Non-TTY Environments: When running shell scripts or commands via automation tools (like Jenkins, GitHub Actions, etc.), there is often no TTY associated with the process, which can confuse certain interactive programs or commands.
- Incorrect Command Usage: The command to authenticate with ECR may be misconfigured or executed in a non-interactive context where it expects user inputs.
- Scripted Environments: Using the ECR login commands in a CI/CD pipeline or other scripted environments without proper adjustments can lead to this error.
Resolving the Error
Use the $(aws ecr get-login-password) Command
The error is often encountered when copying commands directly from Amazon Container Services interfaces, which are typically intended for interactive use. Here's a solution for non-interactive sessions:
- Explanation:
aws ecr get-login-passwordretrieves an authentication token using AWS CLI.docker login --username AWS --password-stdinuses this token to authenticate with your ECR registry.- This method is preferred for non-TTY environments as it does not require interactive input.
Example in a CI/CD Pipeline
For those using Jenkins, GitHub Actions, or similar tools, consider incorporating AWS authentication in your pipeline scripts as follows:
Conclusion
When working with AWS ECR, encountering the "Cannot perform an interactive login from a non TTY device" error typically signals the need to adjust your approach to authentication for a non-interactive environment. Leveraging the aws ecr get-login-password command combined with Docker's --password-stdin option ensures smooth and error-free operations within scripted or automated workflows.
Summary Table
| Issue | Cause | Solution |
| "Cannot perform an interactive login from a non TTY device" | Non-interactive session Interactive commands in automation Misconfigured authentication | Use aws ecr get-login-password with Docker
Employ script adaptations for CI/CD |
This implementation helps override the interactive requirement, making it scalable and adaptable across various development and deployment strategies.
Related reading
- AWS ECS agent won't start
- AWS ECS Error when running task No Container Instances were found in your cluster
- AWS ECS exec /usr/local/bin/docker-entrypoint.sh exec format error
- AWS ECS Fargate and port mapping
- AWS ECS 503 Service Temporarily Unavailable while deploying
- AWS ECS error Task failed ELB health checks in Target group
- AWS ECS Fargate Container Healthcheck command
- AWS ElasticBeanstalk can't find Dockerfile

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.