Home >Operation and Maintenance >Docker >How to modify the system time of docker container
Problem restoration:
1. Run the docker container in the normal way
docker run -it --rm --name centos centos /bin/bash
2. After entering the container, execute the instruction to modify the container time
date -s 08/24/2006 date -s 13:02:00
will give the error date: cannot set date: Operation not permitted.
So how can we modify the time of the container?
The solution is as follows:
1. Exit the previous container and re-enter the container as follows
docker run -it --cap-add SYS_TIME --rm --name centos centos /bin/bash
2. Enter the container and use the command
date -s 08/24/2006 date -s 13:02:00
to modify the time. At this time, the modification can be successful.
Recommended tutorial: docker tutorial
The above is the detailed content of How to modify the system time of docker container. For more information, please follow other related articles on the PHP Chinese website!