티스토리 뷰

___리눅스

[docker] 도커 컨테이너 시간 설정(timezone)

변군 변군이글루 2020. 10. 27. 16:27

도커 컨테이너 시간 설정

 

docker run

$ docker run -it --rm -v /usr/share/zoneinfo/Asia/Seoul:/etc/localtime:ro centos bash
[root@5574276d2005 /]# date
Tue Oct 27 16:20:02 KST 2020

 

docker-compose(volume 마운트)

$ cat docker-compose.yml
version: '3.2'
services:
  centos:
    container_name: centos
    entrypoint: bash -c "while [ 0 ]; do sleep 2; done"
    hostname: centos
    image: centos
    restart: on-failure
    volumes:
      - /usr/share/zoneinfo/Asia/Seoul:/etc/localtime:ro

$ docker-compose ps
 Name     Command    State   Ports
----------------------------------
centos   /bin/bash   Up

$ docker-compose exec centos bash
[root@centos /]# date
Tue Oct 27 16:31:35 KST 2020

 

docker-compose(volume 마운트)

$ cat docker-compose.yml
services:
  centos:
    container_name: centos
    hostname: centos
    image: centos
    restart: on-failure
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    volumes:
    - /usr/share/zoneinfo/Asia/Seoul:/etc/localtime:ro

$ docker-compose ps
 Name     Command    State   Ports
----------------------------------
centos   /bin/bash   Up

$ docker-compose exec centos bash
[root@centos /]# date
Tue Oct 27 16:31:35 KST 2020

 

$ vim docker-compose.yml

...

stdin_open: true # docker run -i

tty: true # docker run -t

 

 

 

댓글
댓글쓰기 폼