공부합시다!/Container

httpd export, import

간서치 2022. 7. 18. 21:14
728x90

apache web server를 container에서 export

그리고 해당 파일은 import해서 image로 전환

해당 image를 실행하면 설정 및 환경변수등이 초기화 되기 때문에 실행이 되지 않습니다.

 

이 문제를 해결하려면

import시 CMD 작업, 그리고 실행 시 환경변수를 추가해 주면 해결이 가능합니다.

 

docker import --change 'CMD ["httpd-foreground"]' http.tar httpd:sdkim
docker run -itd -e "PATH=/usr/local/apache2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" -p 61000:80 --name h1 httpd:sdkim

위 두개의 작업을 하나의 작업으로 구성
docker import --change 'CMD ["httpd-foreground"]' --change 'Env PATH=/usr/local/apache2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' httpd.tar httpd:sdkim1

 

참고로 CentOS:7은 간단하게 /bin/bash만 import시 변경해 주면 되세요!

docker import --change 'CMD ["/bin/bash"]' cent.tar centos:sdkim

 

728x90