Answer the question
In order to leave comments, you need to log in
How to change date in docker container?
It is required to set the year 2027 in the container, OS - debian 8,
issues
a command
Or should the time be changed on the host machine? Although this is highly undesirable.
UPD. In order to cut off the options for answers related to rights, here is a screen of the terminaldate --set 2027-12-16
date: cannot set date: Operation not permitted
Answer the question
In order to leave comments, you need to log in
Perhaps you should do it as root or with su/sudo? ;-)
Source :
That's not possible with Docker. Docker uses the same clock as the outside kernel. What you need is full virtualization which emulates a complete PC.
The sudo fails because it only makes you root of the virtual environment inside of the container. This user is not related to the real root of the host system (except by name and UID) and it can't do what the real root could do.
In you use a high level language like Python or Java, you often have hooks where you can simulate a certain system time for tests or you can write code which wraps "get current time from system" and returns what your test requires.
Maybe this will help you
manpages.ubuntu.com/manpages/trusty/man1/faketime....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question