wasup
docker) 기본 명령어 테스트 본문
현재 진행중인 프로세스 상황(ps)
docker ps
이전&현재 진행중인 프로세스 상황(ps)
docker ps -a
C:\Users\W>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
이미지 다운
docker pull 이미지명:tag
(버전 명시가 없으면 최신버전)
docker pull mysql
C:\Users\W>docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
f7ec5a41d630: Downloading [=> ] 552.1kB/27.14MB 9444bb562699: Pulling fs layer 6a4207b96940: Pulling fs layer 181cefd361ce: Waiting 8a2090759d8a: Waiting 15f235e0d7ee: Waiting d870539cd9db: Waiting 493aaa84617a: Waiting bfc0e534fc78: Waiting fae20d253f9d: Waiting 9350664305b3: Waiting e47da95a5aab: Pulling fs layer
다운받은 이미지 목록 확인
docker images
C:\Users\W>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest 0627ec6901db 2 weeks ago 556MB
컨테이너 실행
docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=1234 --name mysql1 mysql --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
컨테이너로 진입
docker exec -it mysql1 bash
mysql -u root -p
C:\Users\W>docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=1234 --name mysql1 mysql --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
f668fc6c47e6738b7ba94570a4ece3bf7ec3144f243f0f29bf0fd69eb3662625
C:\Users\W>docker exec -it mysql1 bash
root@f668fc6c47e6:/# 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.0.24 MySQL Community Server - GPL
Copyright (c) 2000, 2021, 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.
show databases; #확인
-> show databases;
+--------------------+
| Database |u have an error in your SQL syntax; check the manual that corresponds to your MySQL server vers
+--------------------+ax to use near 'docker ps
| information_schema |
| mysql |e 1
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
exit
mysql> exit
Bye
root@f668fc6c47e6:/# exit
exit
C:\Users\W>
다시 접속 확인
C:\Users\W>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f668fc6c47e6 mysql "docker-entrypoint.s…" 18 minutes ago Up 18 minutes 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql1
C:\Users\W>docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=1234 --name mysql1 mysql --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
docker: Error response from daemon: Conflict. The container name "/mysql1" is already in use by container "f668fc6c47e6738b7ba94570a4ece3bf7ec3144f243f0f29bf0fd69eb3662625". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
C:\Users\W>docker exec -it mysql1 bash
root@f668fc6c47e6:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.24 MySQL Community Server - GPL
Copyright (c) 2000, 2021, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye
root@f668fc6c47e6:/#
root@f668fc6c47e6:/# exit
exit
C:\Users\W>
중지
docker stop mysql1
C:\Users\W>docker stop mysql1
mysql1
C:\Users\W>;
C:\Users\W>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
C:\Users\W>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f668fc6c47e6 mysql "docker-entrypoint.s…" 21 minutes ago Exited (0) 42 seconds ago mysql1
시작
docker start mysql1
컨테이너 삭제
C:\Users\W>docker rm
"docker rm" requires at least 1 argument.
See 'docker rm --help'.
Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...]
Remove one or more containers
C:\Users\W>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f668fc6c47e6 mysql "docker-entrypoint.s…" 40 minutes ago Exited (0) 6 minutes ago mysql1
이하 메모
-현재 진행중인 프로세스 상황(ps)
docker ps
-이전/현재 진행중인 프로세스 상황(ps)
docker ps -a
- 도커이미지 다운
docker pull 이미지명:tag
-이미지 목록
docker imagaes
-새 컨테이너 실행
docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=1234 --name mysql1 mysql --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
-컨테이너로 진입
docker exec -it mysql1 bash
-mysql CLI실행
mysql -u root -p
-mysql CLI 종료 & 나오기
exit
-컨테이너 나오기
exit
-컨테이너 중지
docker stop mysql1
- 컨테이너 시작
docker start mysql1
- 컨테이너 삭제
docker rm mysql1
- 이미지 삭제
docker rmi mysq(이미자명)
'DataBase' 카테고리의 다른 글
Oracle) 설치 - OracleXE112_Win64, 접속, 삭제방법 (0) | 2021.08.12 |
---|---|
H2) MySQL계열 데이터베이스 (0) | 2021.08.05 |
SQL? NOSQL?? (0) | 2021.07.24 |
DB)Connextion Pool (0) | 2021.06.10 |
docker) 설치 (0) | 2021.05.17 |