0
爲什麼我的docker數據卷在主機系統上是空的?爲什麼docker build後node_modules爲空?
當docker-compose up
完成後,我可以進入碼頭集裝箱並查看node_modules
目錄,在那裏我可以看到所有模塊安裝成功。但是當我在我的主機上檢查我的node_modules
目錄時,我什麼也看不到,它是空的。
這裏是Dockerfile:
FROM ubuntu:14.04
WORKDIR /var/www/html
COPY src/package.json /var/www/html/package.json
# install curl, apache, php
RUN DEBIAN_FRONTEND=noninteractive \
apt-get -y update && \
apt-get -y install software-properties-common python-software-properties && \
add-apt-repository ppa:ondrej/php && \
apt-get -y update && \
apt-get install -y --force-yes \
curl \
apache2 \
php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl
# install PHPUnit
RUN curl -L https://phar.phpunit.de/phpunit.phar -o phpunit.phar && \
chmod +x phpunit.phar && \
mv phpunit.phar /usr/local/bin/phpunit
# install node js 6
RUN NVM_DIR="/root/.nvm" && \
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash && \
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && \
nvm install 6 && \
npm install -g webpack && \
npm install
COPY src/ /var/www/html
EXPOSE 80
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
,這裏是我的搬運工,compose.yml文件:
version: "2"
services:
db:
image: mysql:5.7
volumes:
- "./.data/db:/var/lib/mysql"
restart: always
environment:
MYSQL_ROOT_PASSWORD: abc
MYSQL_DATABASE: abc
MYSQL_USER: abc
MYSQL_PASSWORD: abc
wordpress:
build: .
restart: always
depends_on:
- db
links:
- db
ports:
- "8000:80"
volumes:
- ./src:/var/www/html
- /var/www/html/node_modules