본문 바로가기
MySQL/MySQL Installation

Docker MySQL8.0 설치

by 의미와의미 2024. 7. 4.
반응형
[root@ts-oracle1 ~]# docker -v

Docker version 25.0.3, build 4debf41

-- 도커 프로세스 확인
[root@ts-oracle1 ~]# ps -ef | grep docker
root     17862 31576  0 15:09 pts/2    00:00:00 grep --color=auto docker

-- 도커상태 확인
[root@ts-oracle1 ~]# systemctl status docker

* docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: https://docs.docker.com

-- 도커수행
[root@ts-oracle1 ~]# systemctl enable --now docker


Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

-- 도커상태 확인

[root@ts-oracle1 ~]# systemctl status docker
* docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2024-07-04 15:11:49 KST; 2s ago
     Docs: https://docs.docker.com
 Main PID: 22669 (dockerd)
    Tasks: 14
   Memory: 124.9M
   CGroup: /system.slice/docker.service
           `-22669 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Jul 04 15:11:48 ts-oracle1 systemd[1]: Starting Docker Application Container Engine...
Jul 04 15:11:48 ts-oracle1 dockerd[22669]: time="2024-07-04T15:11:48.291055562+09:00" level=info msg="Starting up"
Jul 04 15:11:48 ts-oracle1 dockerd[22669]: time="2024-07-04T15:11:48.361414410+09:00" level=error msg="Failed to built-in GetDriver graph btrfs /var/lib/docker"
Jul 04 15:11:48 ts-oracle1 dockerd[22669]: time="2024-07-04T15:11:48.395041323+09:00" level=info msg="Loading containers: start."
Jul 04 15:11:49 ts-oracle1 dockerd[22669]: time="2024-07-04T15:11:49.011548291+09:00" level=info msg="Default bridge (docker0) is assigned with an IP a... address"
Jul 04 15:11:49 ts-oracle1 dockerd[22669]: time="2024-07-04T15:11:49.060014049+09:00" level=info msg="Loading containers: done."
Jul 04 15:11:49 ts-oracle1 dockerd[22669]: time="2024-07-04T15:11:49.077860626+09:00" level=info msg="Docker daemon" commit=f417435 containerd-snapshot...on=25.0.3
Jul 04 15:11:49 ts-oracle1 dockerd[22669]: time="2024-07-04T15:11:49.078059240+09:00" level=info msg="Daemon has completed initialization"
Jul 04 15:11:49 ts-oracle1 dockerd[22669]: time="2024-07-04T15:11:49.108708525+09:00" level=info msg="API listen on /run/docker.sock"
Jul 04 15:11:49 ts-oracle1 systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.


-- 도커 프로세스 확인
[root@ts-oracle1 ~]# ps -ef | grep docker

root     22669     1  0 15:11 ?        00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root     25678 31576  0 15:13 pts/2    00:00:00 grep --color=auto docker




-- #MySQL 설치

[root@ts-oracle1 12cse]# docker pull mysql:8.2.0

8.2.0: Pulling from library/mysql
558b7d69a2e5: Pull complete
599b67b0dd6a: Pull complete
50314d46ce2b: Pull complete
494babc92263: Pull complete
02548e6f2dbf: Pull complete
a9e5e2637e0d: Pull complete
657b198fe6b7: Pull complete
215a2b0eabbf: Pull complete
377a4c7a89c5: Pull complete
4bfe599fe218: Pull complete
Digest: sha256:212fe73edca5df6ff14826d5eb975c914bfb91f82a2e923f9050568f99525da1
Status: Downloaded newer image for mysql:8.2.0
docker.io/library/mysql:8.2.0




-- mysql 도커생성
[root@ts-oracle1 ~]# docker run --name mysql-container -e MYSQL_ROOT_PASSWORD=1234 -d -p 3306:3306 mysql:8.2.0
415a1a26aad4050e29312a5dcdc333b435bd19de18f673a8a2ca4adfb02e32ac

-- 모든 컨테이너 확인
[root@ts-oracle1 ~]# docker ps -a

CONTAINER ID   IMAGE         COMMAND                  CREATED          STATUS         PORTS                                                  NAMES
415a1a26aad4   mysql:8.2.0   "docker-entrypoint.s…"   12 seconds ago   Up 4 seconds   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   mysql-container

-- 접속
[root@ts-oracle1 ~]# docker exec -it mysql-container mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.2.0 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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> CREATE DATABASE test;
Query OK, 1 row affected (0.00 sec)

mysql>

-- 환경변수에 등록하여 도커를 수행합니다.
vi .bash_profile

alias dme='docker exec -it mysql-container bash'
alias drm='docker restart mysql-container'

[root@ts-oracle1 ~]# docker exec -it mysql-container bash
bash-4.4#

[root@ts-oracle1 ~]# dme
bash-4.4#

 

반응형

댓글