
Dockerfile 아래에서 컨테이너를 빌드합니다.
FROM ubuntu:14.04
...
RUN apt-get update && apt-get install -y vim
#RUN ssh-keygen -f /root/.ssh/id_rsa -N strongpass123$%^
RUN ssh-keygen -f /root/.ssh/id_rsa
...
아주 드물게 사용하지만, 사용 전과 사용 후 명령이 많습니다 ssh-keygen
.
스크립트부터 docker exec -it thirsty_darwin sh script.sh
이미지 태그까지 수행한 다음 컨테이너(이미지) 연결을 사용할 수 있다는 것을 알고 있지만 원하는 만큼 명확한 솔루션은 아닙니다.
ssh-add ~/.ssh/id_rsa
최악의 경우라도 Expect 도구를 사용해야 하는 경우 가 있습니다 . 예상 도구가 내 비밀번호를 하드코딩했습니다. 나는 그것을하고 싶지 않습니다.
답변1
일반적으로 Docker 이미지에는 비밀을 포함하면 안 됩니다. 보다이 답변이 주제에 대한 자세한 내용은
Docker는 대화형 빌드를 지원하지 않습니다.이번 호에 설명된 타당한 이유로.
docker commit
정말로 이 작업을 수행해야 하는 경우 다음과 같이 사용할 수 있습니다 .
docker build -t thirsty_darwin_base /path/to/Dockerfile
docker run -it --name=thirsty_darwin_changes thirsty_darwin_base /bin/bash
# do interactive stuff in the shell, then exit
docker commit thirsty_darwin_changes thirsty_darwin
이제 thirsty_darwin
대화형 변경 사항이 있습니다.
업데이트: Docker가 출시되었습니다.더욱 포괄적인 비밀 관리이 답변이 작성되었으므로.