DEV Community

Yasuhiro Matsuda for AWS Community Builders

Posted on

2

How to system test with fixed time on Fargate

How do you perform system tests with fixed time on Fargate?

I considered logging into the container using the aws ecs execute-command and changing the time using the date command, but since privileged containers aren't supported on Fargate I get the following error occurred and I was unable to change it.

date: cannot set date: Operation not permitted

However, you can adjust the system time by using libfaketime. Although the version is old, the Dockerfile verified with Keycloak 19.0.2 image is shown below.

FROM quay.io/keycloak/keycloak:19.0.2 AS builder

USER root

RUN microdnf install -y git make gcc
RUN git clone https://github.com/wolfcw/libfaketime.git
WORKDIR /libfaketime/src
RUN make install
ENV LD_PRELOAD=/usr/local/lib/faketime/libfaketime.so.1

ENV FAKETIME="2025-04-24 10:30:00"
RUN date

WORKDIR /opt/keycloak

ENTRYPOINT [ "/opt/keycloak/bin/kc.sh" ]
Enter fullscreen mode Exit fullscreen mode

If you enter the container and execute the date command as shown below, you will see that the value specified by the FAKETIME variable is fixed.

% aws ecs execute-command --cluster _clustername_ --task _taskID_ --interactive --command "/bin/bash"

The Session Manager plugin was installed successfully. Use the AWS CLI to start a session.

Starting session with SessionId: ecs-execute-command-xxxxxxxxx
[root@ip-NNN-NNN-NNN-NNN keycloak]# date
Thu Apr 24 10:30:00 UTC 2025
Enter fullscreen mode Exit fullscreen mode

Please try it yourself.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Best Practices for Running  Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK cover image

Best Practices for Running Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK

This post discusses the process of migrating a growing WordPress eShop business to AWS using AWS CDK for an easily scalable, high availability architecture. The detailed structure encompasses several pillars: Compute, Storage, Database, Cache, CDN, DNS, Security, and Backup.

Read full post