使用docker run运行容器,某个程序需要将日期改为2019年才能运行
使用date -s 修改日期不生效
安装libfaketime修改日期:
安装:
wget https://github.com/wolfcw/libfaketime/archive/master.zip
apt-get install make gcc
unzip master.zip
cd libfaketime-master
make && make install
使用:
export LD_PRELOAD=/usr/local/lib/faketime/libfaketime.so.1 FAKETIME="@2019-7-7 10:10:10"
再使用date查看日期已经修改,只对当前会话生效,需要的话可以在docker启动容器时指定环境变量