Dock,Boot2docker和Virtualbox

时间:2016-03-06 11:59:00

标签: docker boot2docker docker-compose

我正在尝试使用Dockerfile和Docker在本地使用Boot2docker / Virtualbox在Mac Yosemite上构建一个Apache Web项目。一切都有效 - 除了一件事 - 对已安装卷的文件权限。我需要有一些PHP可写的文件夹,我无法找到一种方法来更改我的构建中的权限。

这是我的Dockerfile:

FROM ubuntu:latest

RUN apt-get update
RUN apt-get -y upgrade

# Install apache, PHP, and supplimentary programs. curl and lynx-cur are for debugging the container.
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install apache2 libapache2-mod-php5 php5-mysql php5-gd php-pear php-apc php5-curl curl lynx-cur

# Enable apache mods.
RUN a2enmod php5
RUN a2enmod rewrite

# Update the PHP.ini file, enable <? ?> tags and quieten logging.
RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php5/apache2/php.ini
RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" /etc/php5/apache2/php.ini

# Manually set up the apache environment variables
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid

EXPOSE 80

# Update the default apache site with the config we created.
COPY apache-config.conf /etc/apache2/sites-available/000-default.conf

# By default, simply start apache.
CMD /usr/sbin/apache2ctl -D FOREGROUND

这是/build/docker-compose.yml:

web:
   build: ../.
   ports:
       - 8080:80
   volumes:
       - ../www:/var/www/site
   links:
       - mysql
mysql:
   image: mysql:5.6
   ports:
       - 3306:3306/tcp
   restart: on-failure
   environment:
       - MYSQL_ROOT_PASSWORD=demo
       - MYSQL_DATABASE=demo
       - MYSQL_USER=demo
       - MYSQL_PASSWORD=demo

我需要在/ var / www / site中有一些目录可写。尝试了chmod和chown的各种替代方案,但似乎无法在docker容器中做任何事情......

整个项目位于/ Users文件夹中。

我的网络容器上的Docker检查为我提供了以下安装:

"Mounts": [
    {
        "Source": "/Users/[myuser]/Documents/[project]/www",
        "Destination": "/var/www/site",
        "Mode": "rw",
        "RW": true
    },
    {
        "Source": "/mnt/sda1/var/lib/docker/volumes/9018974b47f606c262fc1127a2a9ca6420841ca59a3a064e9adee6a6bfacd70f/_data",
        "Destination": "/var/www",
        "Mode": "rw",
        "RW": true
    },
    {
        "Name": "8105b731c655cdaf53d93c2e78a4a3104d4650b49df5879c2004a2aef3a7d9e0",
        "Source": "/mnt/sda1/var/lib/docker/volumes/8105b731c655cdaf53d93c2e78a4a3104d4650b49df5879c2004a2aef3a7d9e0/_data",
        "Destination": "www",
        "Driver": "local",
        "Mode": "",
        "RW": true
    }

所以我想一切都按照应有的方式安装?我似乎无法获得权限。

0 个答案:

没有答案