ubuntu
1 | RUN echo "Asia/Shanghai" > /etc/timezone RUN dpkg-reconfigure -f noninteractive tzdata |
运行中的 container
如果你不想新建镜像或者重启 container,那么也可以直接进入 container 修改。执行:1
2docker exec -it <CONTAINER NAME> bash
```
进入 container 之后执行:
```bash
echo "Asia/Shanghai" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
alpine
1 | RUN apk add -U tzdata |
参考源代码1
2
3
4
5
6
7
8
9
10
11
12
13
14
15docker run -it --rm alpine /bin/sh
/ # date
Sun May 8 20:46:18 UTC 2016
/ # apk add -U tzdata
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
(1/1) Installing tzdata (2015g-r0)
Executing busybox-1.24.1-r7.trigger
OK: 8 MiB in 12 packages
/ # cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime
/ # date
Sun May 8 22:46:45 CEST 2016
/ #
As a side