Skip to Content
Suffering builds character
아카이브25.devopsDocker특징1.컨테이너 관리11.실행 중인 컨테이너 내부로 진입

11.실행 중인 컨테이너 내부로 진입

1. 실행 중인 컨테이너 목록 조회

terminal
docker ps

실행 결과

terminal
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e1def7150dee diamol/ch02-hello-diamol-web "httpd-foreground" 17 minutes ago Up 17 minutes 0.0.0.0:8080->80/tcp, :::8080->80/tcp objective_mendeleev

2. 컨테이너 내부로 진입

docker exec 명령어를 통해 실행 중인 컨테이너 내부로 진입할 수 있음

terminal
docker exec -i -t objective_mendeleev /bin/sh

-i(--interactive) 대화형 쉘 이용

-t(--tty) 터미널을 통해 컨테이너 조작

위와 동일한 명령어

terminal
docker exec --interactive --tty objective_mendeleev /bin/sh

실행 결과

terminal
/usr/local/apache2 #

3. 현재 경로 조회

여기서는 컨테이너 내부 쉘에서 명령어를 수행해야함

terminal
ls

4. index.html 파일이 위치한 경로로 이동

terminal
cd htdocs

해당 경로 내 목록 조회

terminal
ls

실행 결과

terminal
index.html

5. 파일 내용 조회

terminal
cat index.html

실행 결과

index.html
<html> <body> <h1> Hello from Chapter 2! </h1> <h2> This is <a href="https://www.manning.com/books/learn-docker-in-a-month-of-lunches">Learn Docker in a Month of Lunches</a>. </h2> </body> </html>

6. 파일 내용 수정

index.html 파일 내용을 Hello에서 Hi로 수정 후 Public IP 주소로 다시 요청하여 파일의 내용이 변경된 대로 응답되었는지 확인

Last updated on