Docker Container 접속 및 index.html 변경

히태하태·2021년 8월 21일
0

Docker

목록 보기
3/3

1. docker exec
docker 의 생성된 container의 명령어를 실행하여 command 를 실행 할 수 있다.
docker docs 에서 exec 사용법을 참고한다. (https://docs.docker.com/engine/reference/commandline/exec/)

  • container에 command 전달
    docker exec {container_name} {command}
  • 쉘 실행
    docker exec ws1 /bin/sh

docker exec -it {container_name} {shell 경로}
docker exec -it ws1 /bin/sh

2. index.html 변경

httpd Image 의 docs에서 index.html 을 제공하는 디렉토리 정보를 찾아본다.
https://hub.docker.com/_/httpd

해당 경로를 들어가보면 index html 확인 가능

httpd containter directory 를 host의 directory 로 매핑.
container에서 경로내 파일을 수정 할 필요 없이, host 의 경로로 관리 할 수 있다.

docker run -v {host 경로}:{container 경로} httpd
docker run -p 8888:80 -v ~/Desktop/htdocs:/usr/local/apache2/htdocs/ httpd

설정 할 Host 경로에 index.html 생성

profile
시작이 반이다. 일단 시작해보자.

0개의 댓글