docker/mysql 기준 시간대 변경

2018.10.12 15:39docker

Docker Container Bash  Timezone 설정

#컨테이너 접속

> docker exec -it d14292ef0736 /bin/bash

# 지역 선택 후 아시아 서울 지정 

> tzselect

> export TZ='Asia/Seoul'

#. profile 에 적용

TZ='Asia/Seoul'; export TZ   #<<< 마지막 줄에 추가 

Docker Run Timezone 설정

    #image: mysql:5.7.21
    build: .
    #container_name: mysql_container
      - "3306:3306"
      - TZ=Asia/Seoul

volumes link 방법 

    - "/etc/timezone:/etc/timezone:ro"
    - "/etc/localtime:/etc/localtime:ro"

docker run 에서 link

docker run [other parameters] -v /etc/timezone:/etc/timezone -v /etc/localtime:/etc/localtime

Docker & Mysql 

타임존이 등록되어 있는지 확인

select, a.time_zone_id  from mysql.time_zone a, mysql.time_zone_name b where a.time_zone_id = b.time_zone_id and like '%Seoul';

Docker mysql bash 

[root@test sss]# docker exec -it d14292ef0736 /bin/bash

root@d14292ef0736:/# mysql -u root -p

Enter password: 

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

root@d14292ef0736:/# mysql -u root -p

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 13

Server version: 5.7.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SET GLOBAL time_zone='Asia/Seoul';;

Query OK, 0 rows affected (0.00 sec)

mysql> set time_zone='Asia/Seoul';

Query OK, 0 rows affected (0.00 sec)

mysql> SELECT @@global.time_zone, @@session.time_zone, @@time_zone;

'docker' 카테고리의 다른 글

docker-compose 예제  (0) 2019.06.21
Docker-Compose 설명  (0) 2019.06.21
Dockerfile command / Attribute 명령어 설명  (0) 2019.06.21
docker 기본 명령어 및 설명  (0) 2019.06.21
docker- compose [cassandra / mysql]  (0) 2019.06.05
docker/mysql 기준 시간대 변경  (0) 2018.10.12
1 2 3 4 5 6