简体   繁体   English

docker容器在启动时不会挂载映射卷的内容

[英]docker container does not mount content of mapped volume on start

I have the following docker compose file which runs fine when I do docker-compose up but once I restart the machine, the container php53 does not mount the content of /home/madiba/Development/docker_test/www to `/var/www. 我有以下docker compose文件,当我执行docker-compose up时运行良好docker-compose up但是一旦我重启机器,容器php53不会将/home/madiba/Development/docker_test/www的内容装载到`/ var / www。 If I restart it's mounted! 如果我重新启动,它将被安装! This is running on Ubuntu 16.04 server. 它在Ubuntu 16.04服务器上运行。 Setting up the same container on my laptop running similar version of Ubuntu runs fine. 在运行类似版本Ubuntu的笔记本电脑上设置相同容器运行正常。

version: '2.0'

services:
db:

 image: mysql:5.5
 container_name: mysql5
 volumes:
   - "/home/madiba/Development/docker_test/mysql55_storage:/var/lib/mysql"

 ports:
   - "3355:3306"  
 restart: always
 environment:
   MYSQL_ROOT_PASSWORD: pass


php53:

 build: /home/madiba/Development/docker_test/php53
 container_name: php53

 ports:
   - "5533:80"
 volumes:
     - "/home/madiba/Development/docker_test/www:/var/www"

 depends_on:
   - db

 links:
   - db

 restart: always
 environment:
   display_errors: 'Off'
   PHP_ERROR_REPORTING: E_ALL & ~E_STRICT & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED

The Dockerfile: Dockerfile:

FROM ubuntu:12.04
MAINTAINER madiba <madiba@gmail.com>

# disable interactive functions
ENV DEBIAN_FRONTEND noninteractive

VOLUME ["/var/www"]

RUN apt-get update && \
apt-get install -y \
  apache2 \
  php5 \
  php5-cli \
  libapache2-mod-php5 \
  php5-gd \
  php5-ldap \
  php5-mysql \
  php5-pgsql \
  php5-mcrypt \
  php5-json \
  curl \
  libcurl3-dev \
  php5-curl \
  nano && \
  rm -rf /var/lib/apt/lists/* 

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr /local/bin --filename=composer

RUN composer --version


COPY apache_default /etc/apache2/sites-available/default
COPY run /usr/local/bin/run
RUN chmod +x /usr/local/bin/run
RUN a2enmod rewrite

EXPOSE 80
CMD ["/usr/local/bin/run"]

Your compose file does not seem to be indented correctly. 您的撰写文件似乎缩进不正确。 The second line in the following section does not seem to have correct number of spaces at the beginning of the line. 下一节的第二行似乎在该行的开头没有正确的空格数。 This could be an issue. 这可能是一个问题。

 volumes:
     - "/home/madiba/Development/docker_test/www:/var/www"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM