이미지 저장 디렉토리 만든 후 Dockerfile 작성, 그리고 build
$ mkdir git-from-dockerfile
$ cd git-from-dockerfile
$ cat > Dockerfile
From ubuntu:bionic
RUN apt-get update
RUN apt-get install -y git
$ docker build -t ubuntu:git-from-dockerfile .
Sending build context to Docker daemon 3.072kB
Step 1/3 : FROM ubuntu:bionic
---> 4e5021d210f6
Step 2/3 : RUN apt-get update
...
---> c2110a74f55e
Step 3/3 : RUN apt-get install -y -qq git
...
---> cc770735315e
Successfully built cc770735315e
Successfully tagged ubuntu:git-from-dockerfile
// 확인
$ docker run -it ubuntu:git-from-dockerfile bash
root@f98f0bd06b67:/# git --version
git version 2.17.1
RUN apt-get update &&\
apt-get -qq -y install git curl build-essential apache2 php5 libapache2-mod-php5 rcs
WORKDIR /tmp
RUN \
curl -L -O https://github.com/wkpark/moniwiki/archive/v1.2.5p1.tar.gz &&\
tar xf /tmp/v1.2.5p1.tar.gz &&\
mv moniwiki-1.2.5p1 /var/www/html/moniwiki &&\
chown -R www-data:www-data /var/www/html/moniwiki &&\
chmod 777 /var/www/html/moniwiki/data/ /var/www/html/moniwiki/ &&\
chmod +x /var/www/html/moniwiki/secure.sh &&\
/var/www/html/moniwiki/secure.sh
RUN a2enmod rewrite
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
EXPOSE 80
CMD bash -c "source /etc/apache2/envvars && /usr/sbin/apache2 -D FOREGROUND"
빌드
$ docker build -t nacyot/moniwiki:latest .
Sending build context to Docker daemon 7.68kB
Step 1/10 : FROM ubuntu:14.04
...
Successfully built 408c35f3d162
Successfully tagged nacyot/moniwiki:latest
실행 확인
$ docker run -d -p 9999:80 nacyot/moniwiki:latest
746443ad118afdb3f254eedaeeada5abc2b125c7263bc5e67c2964b570166187
-d 는 daemon (반대로 -i는 interactive)
-p 는 포트포워딩