修改单个容器时间(不修改宿主机)

2019-11-09

项目地址:https://github.com/wolfcw/libfaketime.git

使用alpine编译,可用于分布构建

FROM alpine:3.10.2

ARG VERSION=8.3.0-r0

RUN apk update \
    && apk add --no-cache gcc==${VERSION} \
    && apk add --no-cache g++==${VERSION} \
    && rm -rf /var/cache/apk/*

RUN wget https://github.com/wolfcw/libfaketime/archive/master.zip \
    && unzip master.zip \
    && cd libfaketime-master
    && make && make install
    && cd ../ && rm -rf libfaketime-master master.zip

make install文件变动

/usr/local/lib/faketime # ls
libfaketime.so.1    libfaketimeMT.so.1

/usr/local/bin # ls
faketime

简单验证,更多查看git文档

~ # date
Sat Nov  9 18:30:08 CST 2019

~ # faketime '2008-12-24 08:15:42' date
Wed Dec 24 08:15:42 CST 2008

# 或

~ # LD_PRELOAD=/usr/local/lib/faketime/libfaketime.so.1 FAKETIME="-2d" date
Thu Nov  7 18:01:05 CST 2019

标题:修改单个容器时间(不修改宿主机)
作者:fish2018
地址:http://www.devopser.org/articles/2019/11/09/1573295897199.html

评论
发表评论