Checklist: Is your application ready for a container cluster?

Andreas Wittig – 28 Nov 2019

Is your application ready to run on a container cluster? Use this checklist to find out whether you are good to deploy your application on Amazon Elastic Container Service (ECS) and AWS Fargate or any other container cluster solution.

Checklist

Does your application fulfill the following five requirements?

✅ Stateless: avoid persisting data

Your application (call it a microservice if you want to) is stateless. Answering a request or processing a job does not rely on reading data stored by previous requests or jobs. This applies to data from memory as well as a local disk.

Instead of that, your application stores data in a SQL/NoSQL database (e.g., RDS or DynamoDB), an in-memory database (Elasticache), or any other fully-managed storage service (e.g., S3).

✅ Logging: write to stdout and stderr

Your application writes log messages to standard output (stdout) and standard error (stderr). Do not write log messages to files. (see Stateless). Docker has built-in support to ship log messages from stdout and stderr to various centralized logging solutions (e.g., CloudWatch Logs). Check out A simple way to manage log messages from containers: CloudWatch Logs to learn more.

✅ Configuration: use environment variables

Your application reads configuration parameters from environment variables (e.g., the database endpoint or any other service endpoint). Do not use files to store the configuration for your application.


Looking for a new challenge?

  • DEMICON

    Senior Lead Cloud Solutions Architect AWS

    DEMICON • AWS Advanced Consulting Partner • Remote (Europe)
    GitLab Terraform K8s EKS Lambda Python Go
  • tecRacer

    Cloud Consultant • Machine Learning & Data Analytics

    tecRacer • Premier AWS Consulting Partner • Germany, Austria, Portugal, and Switzerland
    SageMaker Airflow Athena Redshift

Use a templating engine for configuration files if you are containerizing a legacy application. I prefer envsubst to do so. Alternatively, you could have a look at Dockerizing legacy applications with confd.

✅ Process: restrict to one process

Your container starts exactly one main process. If your application consists of more than one process, split them up into multiple containers. For example, if you run NGINX and PHP-FPM, create two containers.

✅ Remote access: disable SSH

Your container does not start an SSH daemon. Do not install or enable SSH within a container (see Processs). Use docker attach to log into a container if needed for debugging. On top of that, optimize your logging.

✅ Shutdown: avoid canceling requests and jobs

Your application receives KILL signals and shuts down gracefully. Test whether the KILL signal triggered by docker kill leads to your application stopping to answer new requests or start new jobs and terminate after the last request or job has been completed.

  • Does your Dockerfile contain ENTRYPOINT or CMD in shell form? Your main process will not receive any KILL signals.
  • Are you starting your main process from a shell script? Make sure you are using exec to do so.

When using Fargate it is necessary, that your application is able to shutdown gracefully within 2 minutes.

🎉 Summary

Checked all five requirements from the checklist? Happy you! Your application is ready for ECS and Fargate or any other container cluster solution.

📚 eBook and Online Seminar

Do you want to learn more about how to ship your application with Docker? Our ebook and online seminar Rapid Docker on AWS teaches you how to dockerize PHP, Ruby on Rails, Python Django, Java Spring Boot, and Node.js Express applications.

Become a cloudonaut supporter

Andreas Wittig

Andreas Wittig ( Email Twitter LinkedIn Mastodon )

We launched the cloudonaut blog in 2015. Since then, we have published 366 articles, 60 podcast episodes, and 58 videos. It's all free and means a lot of work in our spare time. We enjoy sharing our AWS knowledge with you.

Please support us

Have you learned something new by reading, listening, or watching our content? With your help, we can spend enough time to keep publishing great content in the future. Learn more

$
Amount must be a multriply of 5. E.g, 5, 10, 15.

Thanks to Alan Leech, Alex DeBrie, ANTHONY RAITI, Christopher Hipwell, e9e4e5f0faef, Jason Yorty, Jeff Finley, jhoadley, Johannes Grumböck, Johannes Konings, John Culkin, Jonas Mellquist, Jonathan Deamer, Juraj Martinka, Ken Snyder, Markus Ellers, Oriol Rodriguez, Ross Mohan, Ross Mohan, sam onaga, Satyendra Sharma, Simon Devlin, Thorsten Hoeger, Todd Valentine, Victor Grenu, waldensystems, and all anonymous supporters for your help! We also want to thank all supporters who purchased a cloudonaut t-shirt.