我写了this docker-compose项目。 docker-compose.yml看起来像这样:
version: '3.1'
services:
db:
image: mysql
restart: always
environment:
- MYSQL_DATABASE=mgsv
- MYSQL_USER=mgsv_user
- MYSQL_PASSWORD=mgsvpass
- MYSQL_ROOT_PASSWORD=mysql123
volumes:
- ./mysql:/docker-entrypoint-initdb.d
www:
build: ./mGSV
restart: always
ports:
- 8080:8080
Dockerfile基于PHP容器,看起来像这样。
FROM php:5-apache
RUN apt-get update && apt-get install -y --no-install-recommends \
openjdk-7-jdk \
maven \
git \
&& rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/qunfengdong/mGSV.git
# Move the folder 'mgsv' to DocumentRoot of Apache web server. By default, the DocumentRoot of Apache is /var/www/ (speak to the system administrator to know the exact DocumentRoot).
RUN cd /var/www/html/mGSV \
&& mkdir tmp \
&& chmod -R 777 tmp
RUN cd /var/www/html/mGSV && sed -i.bak "s|'gsv'|'mgsv_user'|" lib/settings.php \
&& sed -i.bak "s|$database_pass = ''|$database_pass = 'mgsvpass'|" lib/settings.php \
&& sed -i.bak "s|cas-qshare.cas.unt.edu|localhost|" lib/settings.php
RUN cp /var/www/html/mGSV/Arial.ttf /usr/share/fonts/truetype/
RUN cd /var/www/html/mGSV/ws \
&& tar -xzf mgsv-ws-server.tar.gz
RUN cd /var/www/html/mGSV/ws/mgsv-ws-server \
&& mvn package
RUN cp -f /var/www/html/mGSV/ws/mgsv-ws-server/target/ws-server-1.0RC1-jar-with-dependencies.jar /var/www/html/mGSV/ws/
RUN cd /var/www/html/mGSV/ws \
&& echo "mgsv_upload_url=http://localhost/mgsv" > config.properties \
&& echo "ws_publish_url=http\://localhost\:8081/MGSVService" >> config.properties \
&& java -jar ws-server-1.0RC1-jar-with-dependencies.jar &
这是我得到的输出:
Step 1/11 : FROM php:5-apache
---> 8f4a38cf4542
Step 2/11 : RUN apt-get update && apt-get install -y --no-install-recommends openjdk-7-jdk maven git && rm -rf /var/lib/apt/lists/*
---> Using cache
---> f194797b9362
Step 3/11 : RUN git clone https://github.com/qunfengdong/mGSV.git
---> Using cache
---> 4acd066da444
Step 4/11 : RUN cd /var/www/html/mGSV && mkdir tmp && chmod -R 777 tmp
---> Using cache
---> f766f9ceb7d3
Step 5/11 : RUN cd /var/www/html/mGSV && sed -i.bak "s|'gsv'|'mgsv_user'|" lib/settings.php && sed -i.bak "s|$database_pass = ''|$database_pass = 'mgsvpass'|" lib/settings.php && sed -i.bak "s|cas-qshare.cas.unt.edu|localhost|" lib/settings.php
---> Using cache
---> 007dff8907f4
Step 6/11 : RUN cp /var/www/html/mGSV/Arial.ttf /usr/share/fonts/truetype/
---> Using cache
---> 026049ca32d8
Step 7/11 : RUN cd /var/www/html/mGSV/ws && tar -xzf mgsv-ws-server.tar.gz
---> Using cache
---> 92a0f85b27a0
Step 8/11 : RUN cd /var/www/html/mGSV/ws/mgsv-ws-server && mvn package
---> Using cache
---> 5aa1723f255f
Step 9/11 : RUN cp -f /var/www/html/mGSV/ws/mgsv-ws-server/target/ws-server-1.0RC1-jar-with-dependencies.jar /var/www/html/mGSV/ws/
---> Using cache
---> f0dbd0ac1ddb
Step 10/11 : RUN cd /var/www/html/mGSV/ws && echo "mgsv_upload_url=http://localhost/mgsv" > config.properties && echo "ws_publish_url=http\://localhost\:8081/MGSVService" >> config.properties && java -jar ws-server-1.0RC1-jar-with-dependencies.jar &
---> Using cache
---> 0c86c0adddd5
但是,当我创建交互式会话时,/var/www/html/
为空:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
php 5-apache 8f4a38cf4542 7 days ago 374MB
$ sudo docker run --entrypoint /bin/bash -i -t 8f4a38cf4542
root@a3908e297bcf:/var/www/html# ls
为什么我看不到docker容器中的/var/www/html/mGSV
文件夹?
提前谢谢。
米甲
答案 0 :(得分:0)
8f4a38cf4542
图片是您在添加之前构建的php:5-apache
基本图片FROM
。
docker-compose
构建输出应在末尾包含一行:Successfully built eccdcc9a9534
,这是您需要从输出和使用中复制的图像ID。您应该能够在完整输出中找到此图像:
docker images -a
为了让生活更轻松,请为image
服务添加www
名称,以便为构建标记代码,并且可以轻松访问:
www:
build: ./mGSV
image: user3523406/www
restart: always
然后
sudo docker run --entrypoint /bin/bash -it user3523406/www