CLOUD CONCEPT

Containers

Containers package applications and their dependencies into isolated processes that run using a compatible host operating-system kernel.

Cloud Concepts Hub →

What is Containers

Containers provide a repeatable way to build, distribute, and run software across development and cloud environments. They improve deployment consistency and resource utilization, but require explicit controls for image security, runtime isolation, networking, identity, and persistent data.

A container is a running instance of a container image: a packaged application filesystem with dependencies and execution metadata. Unlike a virtual machine, a typical container does not boot its own operating-system kernel. Instead, the container runtime uses host operating-system isolation mechanisms to separate processes, filesystems, and resource consumption. On Linux, namespaces provide isolation and control groups govern resources. This shared-kernel model generally allows containers to start quickly and use fewer resources than separate virtual machines.

Images make application delivery repeatable. For example, a team can build an image containing a web API and its required libraries, test it in a pipeline, publish it to a registry, and deploy the same image to production. Portability still has limits: the image must match the supported operating system and processor architecture, and the application may depend on external networking, storage, or cloud APIs. A container image is not the same as an Amazon Machine Image, or AMI. An AMI supplies an EC2 instance's operating-system environment; a container image supplies the application environment executed by a container runtime.

Cloud deployments normally combine a registry, an orchestrator, and compute capacity. The registry stores images, while the orchestrator schedules workloads, maintains the desired number of replicas, and coordinates updates and recovery. Amazon ECS is an AWS-native container orchestration option. Amazon EKS provides managed Kubernetes for teams that need Kubernetes APIs, tooling, or ecosystem integrations. AWS Fargate supplies managed compute for supported ECS and EKS workloads, removing the need to administer the underlying worker instances. ECS and EKS can also use EC2 capacity when workloads require greater host control or particular instance capabilities.

Choose containers for independently deployable APIs, background workers, batch jobs, or applications with conflicting dependency requirements. For example, an API service can scale separately from a queue-processing worker even when both use the same application image with different startup commands. Containers do not automatically make an application stateless: data in a container's writable layer is normally lost when that container is removed. Put durable data in an appropriate database, object store, or persistent volume, and design applications to tolerate replacement.

Image hardening begins during the build. Use maintained, minimal base images, remove unnecessary packages and build tools, install security updates, and run the application as a non-root user where supported. Use multistage builds to keep compilation dependencies out of the final image. Never bake credentials into image layers; deleting a secret in a later layer does not remove it from earlier layers. Scan operating-system packages and application dependencies, verify image provenance, and deploy approved images by digest to identify exact artifacts. A clean vulnerability scan is not proof that an image is secure.

Runtime controls are equally important. Avoid privileged containers and unnecessary host mounts, drop unneeded Linux capabilities, restrict network access, set CPU and memory limits, and use read-only root filesystems where practical. Give each workload narrowly scoped permissions rather than broad access through the host's identity. Because ordinary containers share a kernel, they are not equivalent to virtual machines as a security boundary. Stronger isolation may be necessary for mutually untrusted workloads.

For EC2-backed container hosts, harden the AMI, restrict administrative access, and maintain the kernel, runtime, and host agents. EC2 Image Builder can automate creation and testing of hardened AMIs and container images. AWS Systems Manager can support configuration, controlled administrative access, and patching of managed EC2 hosts; it does not replace rebuilding vulnerable application images. Patch container dependencies by rebuilding, testing, and redeploying images rather than manually changing running containers. Managed compute reduces host administration, but customers still remain responsible for their application code, images, permissions, and workload configuration.

Key aspects of Containers

Containers combine repeatable packaging and efficient execution with explicit responsibilities for orchestration, isolation, image security, host maintenance, and persistent state.

Repeatable application packaging

An image packages application code, dependencies, and execution metadata into a reusable artifact. Promote the same tested image through environments and use its digest to identify the exact version deployed.

Operating-system-level isolation

Containers isolate processes while typically sharing the host kernel. Treat privileged execution, host filesystem mounts, and excessive capabilities as significant reductions in that isolation.

Orchestration separate from compute

An orchestrator schedules containers and maintains desired workload state, while compute capacity provides the resources on which they run. Choose the orchestration interface separately from the decision to manage hosts or use managed compute.

Hardened images and hosts

Minimize image contents, scan dependencies, exclude secrets, and rebuild images when vulnerabilities are fixed. For self-managed worker instances, also harden and patch the host operating system and container runtime.

Least-privilege runtime configuration

Use workload-specific permissions, non-root execution, restricted networking, and resource limits. Avoid unnecessary privileges and protect credentials independently of the image.

Replaceable execution with explicit persistence

Design containers to be stopped and replaced without losing required application state. Store durable data outside the disposable container filesystem and configure health checks and graceful shutdown behavior.

Cloud services for Containers

EC2 Image Builder can produce hardened container images and AMIs for EC2-backed container hosts. Amazon ECR stores the resulting container images for deployment by Amazon ECS or Amazon EKS. ECS provides AWS-native orchestration, while EKS provides Kubernetes orchestration. Both can use supported AWS Fargate configurations to reduce host-management responsibilities, or EC2 capacity when greater host control is required. AWS Systems Manager helps manage and patch EC2 hosts. Together, these services support a controlled build-to-runtime workflow, but engineers must still enforce image approval, least-privilege access, secure runtime settings, and timely workload replacement.

AWS Fargate image AWS Fargate

Fargate provides managed compute for supported ECS and EKS workloads without requiring customers to administer worker instances. Image security, application permissions, and workload configuration remain customer responsibilities.

Open AWS Fargate →
EC2 Image Builder

EC2 Image Builder automates building, customizing, testing, and distributing AMIs and container images. Use repeatable pipelines to apply hardening steps and validate artifacts before deployment.

Open EC2 Image Builder →
AWS Systems Manager image AWS Systems Manager

Systems Manager supports management of EC2 container hosts through capabilities such as configuration automation, Session Manager, and Patch Manager. Use it for host-level controls; update application dependencies by rebuilding and redeploying container images.

Open AWS Systems Manager →