Docker MySQL

2020. 9. 5. 17:20 from Development Log

mysql 도커 이미지 다운로드

% docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
bf5952930446: Pull complete 
8254623a9871: Pull complete 
938e3e06dac4: Pull complete 
ea28ebf28884: Pull complete 
f3cef38785c2: Pull complete 
894f9792565a: Pull complete 
1d8a57523420: Pull complete 
6c676912929f: Pull complete 
3cdd8ff735c9: Pull complete 
4c70cbe51682: Pull complete 
e21cf0cb4dc3: Pull complete 
28c36cd3abcc: Pull complete 
Digest: sha256:6ded54eb1e5d048d8310321ba7b92587e9eadc83b519165b70bbe47e4046e76a
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest

 

도커 이미지 확인

% docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mysql               latest              3646af3dc14a        13 hours ago        544MB

 

컨테이너 생성

% docker run -d --name mysqltest -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql
bf0710b848ce8657971e3d27dfe29f09e2747b96f4d2decedf75410c2e7caad4
% docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES
bf0710b848ce        mysql               "docker-entrypoint.s…"   16 seconds ago      Up 16 seconds       0.0.0.0:3306->3306/tcp, 33060/tcp   mysqltest

 

컨테이너 설정(Volume)

Docker -> Preferences... -> File Sharing.

% docker run -d --name mysqltest -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -v /Users/nubiform/docker/volumes/mysql:/var/lib/mysql mysql

 

컨테이너 접속

% docker exec -it mysqltest bash
root@bf0710b848ce:/# mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.21 MySQL Community Server - GPL

Copyright (c) 2000, 2020, 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
owners.

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

mysql>

 

docker-compose

mysqltest.yml

version: '3'

services:
  mysqltest:
    image: mysql
    restart : always
    ports:
      - 3306:3306
    environment:
      MYSQL_ROOT_PASSWORD: root
    volumes:
      - /Users/nubiform/docker/volumes/mysql:/var/lib/mysql

 

실행

% docker-compose -f mysqltest.yml up -d

'Development Log' 카테고리의 다른 글

React 01  (0) 2020.09.11
Springboot Docker Image  (0) 2020.09.06
OSX OpenJDK 설치  (0) 2020.09.04
April 16, 2013  (0) 2013.04.16
May 16, 2011  (0) 2011.05.16
Posted by NuBiFoRM :