반응형
Mysql 설치
- Unable to find image 'mysql:5.7' locally : 로컬에서 mysql 5.7 버전을 찾을 수 없어 도커 레지스트리에서 이미지를 다운받음 (pull)
docker run --name haenny-mysql -e MYSQL_ROOT_PASSWORD={password} -d -p 3306:3306 mysql:5.7
Unable to find image 'mysql:5.7' locally
5.7: Pulling from library/mysql
20e4dcae4c69: Pull complete
1c56c3d4ce74: Pull complete
e9f03a1c24ce: Pull complete
68c3898c2015: Pull complete
6b95a940e7b6: Pull complete
90986bb8de6e: Pull complete
ae71319cb779: Pull complete
ffc89e9dfd88: Pull complete
43d05e938198: Pull complete
064b2d298fba: Pull complete
df9a4d85569b: Pull complete
Digest: sha256:4bc6bc963e6d8443453676cae56536f4b8156d78bae03c0145cbe47c2aad73bb
Status: Downloaded newer image for mysql:5.7
cca1beb62f9acd90568ae511ce1524e7e3729b52a30a61af4874e650d18dce48
다운받은 도커 이미지 확인
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 5.7 5107333e08a8 4 months ago 501MB
도커가 잘 구동되고 있는지 도커 컨테이너 정보 확인
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
NAMES
cca1beb62f9a mysql:5.7 "docker-entrypoint.s…" 3 minutes ago Up 3 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp
haenny-mysql
mysql container 실행
- 위에서 설정한 password 입력 → mysql 접속
docker exec -it haenny-mysql bash
bash-4.2# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.44 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>
mysql database 생성
create database haenny;
use haenny;
show databases;
mysql> create database haenny;
Query OK, 1 row affected (0.00 sec)
mysql> use haenny;
Database changed
mysql> show databases;
+-----------------------------+
| Database |
+-----------------------------+
| information_schema |
| haenny |
| mysql |
| performance_schema |
| sys |
+-----------------------------+
5 rows in set (0.00 sec)
Mysql 접속 나가기
mysql> quit
Bye
bash-4.2#
Docker 컨테이너 나가기
- 컨테이너 종료없이 나가기 : Ctrl + P + Q
- 컨테이너 중지하며 나가기 : Ctrl + D 혹은 명령어 exit
다시 컨테이너 들어가기
docker attach {컨테이너이름or컨테이너ID}
728x90
반응형
'Infra > Open Source' 카테고리의 다른 글
[Docker] 나 보려고 만든 도커 명령어 모음 (0) | 2024.04.14 |
---|---|
[Docker] 도커 컨테이너 (python app) 구동하기 (0) | 2024.04.14 |
[Kubernetes] K8S 배포 설정 Deployment, Service, Ingress 파악하기 (0) | 2024.02.02 |
[K8S] 파드 CreateContainerError 오류 해결 (0) | 2024.01.30 |
[Kubernetes] 윈도우 환경 kubectl 설치 및 설정하기 (0) | 2024.01.18 |
댓글