λ컀 Docker
Dockerλ 컨ν μ΄λλ₯Ό μ¬μ©ν΄ μ ν리μΌμ΄μ μ μ μνκ² κ΅¬μΆ, ν μ€νΈ λ° λ°°ν¬ν μ μλ μννΈμ¨μ΄ νλ«νΌμ λλ€.
μ λ κ°λ° νκ²½μ μ€λΉνκΈ° μν΄ λ컀 Dockerλ₯Ό νμ©νκ³ μμ΅λλ€.
λ컀 μ€μΉ
μ€μΉ νμΌμ λ΄λ €λ°μ μ€μΉν©λλ€. λ§ν¬λ μλμ°μ¦μμ λ컀λ₯Ό μ¬μ©νκΈ° μν΄ νμν©λλ€.
μ΄λ―Έμ§ κ²μ
MariaDB μ΄λ―Έμ§λ₯Ό κ²μν©λλ€.
PS> docker search mariadb
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mariadb MariaDB is a community-developed fork of MyS⦠2596 [OK]
bitnami/mariadb Bitnami MariaDB Docker Image 86 [OK]
linuxserver/mariadb A Mariadb container, brought to you by Linux⦠59
toughiq/mariadb-cluster Dockerized Automated MariaDB Galera Cluster β¦ 37 [OK]
μ΄λ―Έμ§ λ€μ΄λ‘λ
곡μ μ΄λ―Έμ§λ₯Ό λ€μ΄λ‘λν©λλ€.
PS> docker pull mariadb
컨ν μ΄λ μ€ν
λ€μ΄λ‘λ λ°μ μ΄λ―Έμ§λ‘ 컨ν μ΄λλ₯Ό μ€νν©λλ€.
컨ν μ΄λ μ€ν μΈμμ νκ²½λ³μλ docker hub mariadbμμ νμΈν μ μμ΅λλ€.
docker-compose
docker-composeλ₯Ό μ¬μ©νλ©΄ 컨ν μ΄λ μ€νμ 볡μ‘νκ² μ λ ₯ν΄μΌ νλ μΈμλ₯Ό 미리 μ€λΉνκ³ μ»¨ν μ΄λ μ€ν, μ€μ§, μ κ±° μ μ°¨λ₯Ό μμ½κ² μ²λ¦¬ν μ μμ΅λλ€.
μ λΉν λλ ν°λ¦¬μ docker-compose.yml νμΌμ μλμ λ΄μ©μΌλ‘ μμ±ν©λλ€.
μ¬μ©μ νλ‘ν λλ ν°λ¦¬μ docker λλ ν°λ¦¬λ₯Ό λ§λ€κ³ 컨ν μ΄λ μ΄λ¦μ ν΄λΉνλ mariadb λλ ν°λ¦¬λ₯Ό λ§λ€μμ΅λλ€. κ·Έ μμ config, data λλ ν°λ¦¬λ₯Ό μΆκ°νμ΅λλ€. docker-compose.yml νμΌμ mariadb λλ ν°λ¦¬μ μμ΅λλ€.
μ¬μ©μ νλ‘ν λλ ν°λ¦¬λ μλμ°μ¦ νμκΈ°λ₯Ό μ΄κ³ μ£Όμμ°½μ %userprofile% μ μ λ ₯νλ©΄ λ°λ‘ μ΄λν μ μμ΅λλ€.
PS> tree .
C:\USERS\{username}\DOCKER
ββmariadb
ββconfig
ββdata
docker-compose.yml νμΌμ λ΄μ©μ λλ€.
version: "3.1"
services:
db:
container_name: mariadb
image: mariadb:latest
restart: always
ports:
- 3306:3306
volumes:
- /c/Users/{username}/docker/mariadb/data:/var/lib/mysql
- /c/Users/{username}/docker/mariadb/config:/etc/mysql/conf.d
environment:
MYSQL_ROOT_PASSWORD: { password }
TZ: Asia/Seoul
{username}: μλμ°μ¦ μ¬μ©μ κ³μ μ΄λ¦μΌλ‘ λ³κ²½μ΄ νμν©λλ€. {password}: mariadb root κ³μ μ λΉλ°λ²νΈλ‘ λ³κ²½μ΄ νμν©λλ€. (μνλ κ°μΌλ‘ λ³κ²½ν©λλ€.)
mariadb/config λλ ν°λ¦¬μλ 미리 ꡬμ±ν cnf νμΌμ μΆκ°ν©λλ€.
μ κ° μ¬μ©νλ λ¬Έμμ κ³Ό μ λ ¬μ ꡬμ±ν mariadb.cnf νμΌμ λ΄μ©μ μλμ κ°μ΅λλ€.
# MariaDB-specific config file.
# Read by /etc/mysql/my.cnf
[client]
# Default is Latin1, if you need UTF-8 set this (also in server section)
#default-character-set = utf8
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
#
# * Character sets
#
# Default is Latin1, if you need UTF-8 set all this (also in client section)
#
#character-set-server = utf8
#collation-server = utf8_general_ci
#character_set_server = utf8
#collation_server = utf8_general_ci
# Import all .cnf files from configuration directory
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
!includedir /etc/mysql/mariadb.conf.d/
docker-compose.yml νμΌμ μμ±νμΌλ©΄, ν΄λΉ νμΌμ΄ μλ μμΉμμ μλ λͺ λ ΉμΌλ‘ 컨ν μ΄λλ μμ±νκ³ μ€νν©λλ€.
PS> docker-compose up -d
컨ν μ΄λ μνλ₯Ό νμΈνλ €λ©΄ ps λͺ λ Ήμ μ¬μ©ν©λλ€.
PS> docker-compose ps
The system cannot find the path specified.
Name Command State Ports
----------------------------------------------------------------------
mariadb docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp
컨ν μ΄λλ₯Ό μ€μ§νλ €λ©΄ stop λͺ λ Ήμ μ¬μ©ν©λλ€.
PS> docker-compose stop
컨ν μ΄λλ₯Ό μμνλ €λ©΄ start λͺ λ Ήμ μ¬μ©ν©λλ€.
PS> docker-compose start
컨ν μ΄λλ₯Ό μ κ±°νλ €λ©΄ down λͺ λ Ήμ μ¬μ©ν©λλ€.
ps> docker-compose down