Docker를 사용하여 VOLUME 파일 테스트

2515 단어 volumeDocker
This is how we setup docker
여기에 docker를 설치하는 것을 보십시오
I will implemt this structure.

Create dockerfile for a volume
Dockerfile
FROM centos:latest
MAINTAINER 0.1 [email protected]
RUN ["mkdir", "/var/log/httpd"]
VOLUME /var/log/httpd
Create image
bash
sudo docker build -t log-volume-image .
check it
bash
sudo docker images | grep log
#log-volume-image    latest              ea4362acfb12        11 minutes ago      193MB
Create dockerfile for Apache
Dockerfile
FROM centos
MAINTAINER taro yamada <[email protected]>
# RUN: It executes when it is built
RUN yum -y install httpd
EXPOSE 80
# CMD: It executes when it is running
CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]
bash
sudo docker build -t httpd-image .
check it
bash
sudo docker images | grep httpd
#httpd-image         latest              8d1d89cb6ce4        34 seconds ago      332MB
start container for log
bash
sudo docker run -it --name log-container log-volume-image
start container for httpd
bash
sudo docker run -d --name httpd-container \
                          -p 8080:80 \
                          --volumes-from log-container httpd-image
start another container for httpd. The difference is just name and port.
bash
sudo docker run -d --name httpd-container-2 \
                          -p 8081:80 \
                          --volumes-from log-container httpd-image
You can access here
browser
http://192.168.55.44:8080/
http://192.168.55.44:8081/
check log file. attach container
bash
sudo docker start -ia log-container
You can see a log file by this command
bash
tail -f /var/log/httpd/access_log
You can check also in httpd server.
bash
sudo docker exec -it httpd-container /bin/bash
bash
tail -f /var/log/httpd/access_log

좋은 웹페이지 즐겨찾기