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
- exec option (https://docs.docker.com/engine/reference/commandline/exec/)
-i 입력유지(Keep STDIN open even if not attached)
-t Pseudo Terminal 할당 (Allocate a pseudo-TTY)
docker exec -it {container_name} {shell 경로}
docker exec -it ws1 /bin/sh
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 생성