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

How to modify the system time of docker container

王林
Release: 2020-04-14 10:44:18
Original
6098 people have browsed it

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
Copy after login

2. After entering the container, execute the instruction to modify the container time

date -s 08/24/2006
date -s 13:02:00
Copy after login
Copy after login

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
Copy after login

2. Enter the container and use the command

date -s 08/24/2006
date -s 13:02:00
Copy after login
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template