Docker & AWS & Jenkins 04

김수민·2020년 3월 22일
0

강의 출처 : 동빈나님 유튜브 강의 링크

도커(Docker) 활용 및 배포 자동화 실전 초급 ④ 도커(Docker) 이미지로 Apache 및 PHP 개발환경 구축하기

실행중인 docker container 확인

docker ps -a

실행중인 모든 docker container 강제 삭제

docker rm -f `docker ps -a`

Dockerfile 수정 및 build (php 설치 구문 추가)

FROM ubuntu:18.04
MAINTAINER sumin kim <tn841@naver.com>

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update
RUN apt-get install -y apapche2
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:ondrej/php
RUN apt-get update
RUN apt-get install -y php5.6

EXPOST 80

CMS ['apachectl", "-D", "FROEGROUND"]
  • Dockerfile build시 noninteraction 환결 설정 추가
  • Dockerfile을 많이 작성해보면서 bulid과정에서 발생하는 다양한 오류를 직접 경험해보자.

수정한 example Docker image 실행

docker run -p 80:80 -v /home/ec2-user/example/html:/var/www/html example

# -p <host port>:<container port>
  • -p 옵션으로 container와 ec2서버의 port를 연결
  • -v 옵션으로 container의 특정 디렉터리와 ec2서버의 특정 디렉터리를 연결

container 실행 및 php 확인

80 포트로 실행된 example container를 확인 해보았다.

그러나 php5.6은 설치가 잘못 된 것 같다. index.php 파일을 제대로 출력하지 못하고 있음.

원인 파악이 필요..

또 다른 container 실행

docker run -p 81:80 -v /home/ec2-user/example/html:/var/www/html example

동일한 image를 81번 포트를 열어 새로운 container를 띄울 수 있다.

profile
python developer

0개의 댓글