반응형
1. centos9 image 설치
https://www.centos.org/download/
컨테이너에 이미지로 올릴거기 때문에 이렇게 선택합니다.
centos9은 설치할때 버전을 함께 선택
엉뚱한 버전이 설치될 수도 있기때문에 최대한 원하는 버전으로 선택
vagrant@ubuntu2204:~$ docker pull quay.io/centos/centos:stream9
stream9: Pulling from centos/centos
b4f21276d220: Pull complete
Digest: sha256:f9ac4692a0505202cb05380e3c69461320358db735288c798689502d903dbe37
Status: Downloaded newer image for quay.io/centos/centos:stream9
quay.io/centos/centos:stream9
vagrant@ubuntu2204:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mariadb latest a914eff5d2eb 6 days ago 336MB
quay.io/centos/centos stream9 5ef0f9d95ba6 9 days ago 164MB
nginx latest 97662d24417b 2 weeks ago 192MB
httpd latest 4d98e80840bb 3 weeks ago 148MB
hello-world latest 74cc54e27dc4 4 weeks ago 10.1kB
이렇게 다운로드를 완료했습니다.
<centos9 컨테이너 생성>
# 컨테이너 생성
# 생성은 되었으나 실행되고 바로 종료됨
vagrant@ubuntu2204:~$ docker run -d --name centos quay.io/centos/centos:stream9
23a0421f836347d253d4308569b5b330c0d509a90c094e0efddff5b389989310
vagrant@ubuntu2204:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
vagrant@ubuntu2204:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
23a0421f8363 quay.io/centos/centos:stream9 "/bin/bash" 11 seconds ago Exited (0) 9 seconds ago centos
#centos9이 3600초 동안 컨테이너를 종료되지 않도록 유지
vagrant@ubuntu2204:~$ docker run -d --name centos2 quay.io/centos/centos:stream9 /bin/sleep 3600s
7f98b682cf241526048c0d686ba775d5a58e083e3a5d54192f21378740b8ba71
#실행중인 도커
vagrant@ubuntu2204:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7f98b682cf24 quay.io/centos/centos:stream9 "/bin/sleep 3600s" 7 seconds ago Up 6 seconds centos2
#계속 실행되도록 하는 명령어 -> 백그라운드 실행하지 않음, 터미널과 상호작용
vagrant@ubuntu2204:~$ docker run -d --name centos3 -it quay.io/centos/centos:stream9
53928d9c8491d592ad159f5171c739fe996b8f37897b83ffc82e86d90669dae9
vagrant@ubuntu2204:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
53928d9c8491 quay.io/centos/centos:stream9 "/bin/bash" 4 seconds ago Up 3 seconds centos3
7f98b682cf24 quay.io/centos/centos:stream9 "/bin/sleep 3600s" 35 seconds ago Up 34 seconds centos2
2. mysql image 설치
<mysql 컨테이너 설치>
#mysql 설치
vagrant@ubuntu2204:~$ docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
43759093d4f6: Pull complete
d255dceb9ed5: Pull complete
23d22e42ea50: Pull complete
431b106548a3: Pull complete
2be0d473cadf: Pull complete
f56a22f949f9: Pull complete
277ab5f6ddde: Pull complete
df1ba1ac457a: Pull complete
cc9646b08259: Pull complete
893b018337e2: Pull complete
Digest: sha256:146682692a3aa409eae7b7dc6a30f637c6cb49b6ca901c2cd160becc81127d3b
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest
<mysql 컨테이너 실행>
#컨테이너 실행
vagrant@ubuntu2204:~$ docker run -d --name mydb --env MYSQL_ROOT_PASSWORD=mypass mysql
b83e8514f80bcdd585efc5f208bcb7875213b918bd22f5b3003e7bd6aace8943
#컨테이너 접속
vagrant@ubuntu2204:~$ docker exec -it mydb /bin/bash
bash-5.1#
반응형
'요즘공부' 카테고리의 다른 글
[도커&쿠버네티스] 교육 1일차_ 컨테이너 생성시 삭제되지 않도록 하는 법 (0) | 2025.02.21 |
---|---|
[도커&쿠버네티스] 교육 1일차_ nginx, mariaDB image 설치 (0) | 2025.02.20 |
[도커&쿠버네티스] 교육 1일차_도커 설치 및 httpd 컨테이너 생성,삭제 (0) | 2025.02.16 |
[도커&쿠버네티스] 교육 1일차_사전준비 사항 (0) | 2025.02.15 |
CLASS101 화이트햇 해킹, IT 취준생과 현직개발자를 위한 웹 해킹 입문 강의 공부4 (1) | 2024.12.15 |