Home  >  Article  >  Operation and Maintenance  >  How to modify the system time of docker container

How to modify the system time of docker container

王林
王林Original
2020-04-14 10:44:185966browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn