我正試圖在Vagrant + Docker上部署Symfony 2應用程序。在Vagrant + Docker上的Symfony 2應用程序
Vagrantfile:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/precise64"
# config.vm.synced_folder ".", "/vagrant", owner: 'web', group: 'web'
config.vm.network "forwarded_port", host: 5000, guest: 80
# config.vm.network "forwarded_port", host: 5001, guest: 3306
config.vm.provision "docker" do |d|
d.build_image "/vagrant/Docker", args: "-t site/web"
d.run "site/web", args: "-p 80:80 -v /vagrant/application:/var/www/site"
end
end
Dockerfile:
FROM ubuntu:precise
MAINTAINER umbrella-web <http://umbrella-web.com/>
ENV DEBIAN_FRONTEND noninteractive
WORKDIR/
RUN echo "web:x:web:web::/home/web:/bin/bash" >> /etc/passwd
RUN echo "web:x:web:" >> /etc/group
# policy-rc.d access execution of start
RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d
# Update repositories
RUN apt-get update -y && \
apt-get install python-software-properties -y && \
# add-apt-repository ppa:ondrej/apache2 -y && \
add-apt-repository ppa:ondrej/php5-oldstable -y && \
apt-get update -y && \
apt-get upgrade -y
# isntall packages
RUN apt-get update -y && \
apt-get -y install \
apache2 \
php5 \
php5-mysql \
libapache2-mod-php5 \
rpl \
# phpmyadmin \
php-apc \
# debug packages
curl \
nano
# Enable apache mods.
# RUN a2enmod php5
RUN a2enmod rewrite
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
RUN /etc/init.d/apache2 restart
ADD apache/www /var/www/site
ADD apache/default /etc/apache2/sites-available/default
# RUN touch /var/www/site/index.html
# RUN echo "Hello!!!" /var/www/site/index.html
RUN chown -R www-data:www-data /var/www/site
USER web
EXPOSE 80
# CMD /usr/sbin/apache2ctl -D FOREGROUND
CMD bash
Vagrantfile和Dockerv做工不錯。但是,我在Symfony 2 config.php文件中遇到了主要問題。
Change the permissions of either "app/cache/" or "var/cache/" directory so that the web server can write into it.
Change the permissions of either "app/logs/" or "var/logs/" directory so that the web server can write into it.
由於搬運工容器項目文件的所有者1001這傢伙是誰?
-rw-rw-r-- 1 1001 1001 1065 Oct 6 13:55 LICENSE
-rw-rw-r-- 1 1001 1001 5732 Oct 6 13:55 README.md
-rw-rw-r-- 1 1001 1001 1308 Oct 6 13:55 UPGRADE-2.2.md
-rw-rw-r-- 1 1001 1001 1962 Oct 6 13:55 UPGRADE-2.3.md
-rw-rw-r-- 1 1001 1001 356 Oct 6 13:55 UPGRADE-2.4.md
-rw-rw-r-- 1 1001 1001 8499 Oct 6 13:55 UPGRADE.md
drwxrwxr-x 1 1001 1001 4096 Nov 17 20:44 app
drwxrwxr-x 1 1001 1001 4096 Nov 17 20:43 bin
-rw-rw-r-- 1 1001 1001 2416 Oct 6 13:55 composer.json
-rw-rw-r-- 1 1001 1001 56835 Nov 17 20:43 composer.lock
-rw-r--r-- 1 1001 1001 19 Nov 20 13:49 index.php
drwxrwxr-x 1 1001 1001 4096 Nov 17 21:33 nbproject
drwxrwxr-x 1 1001 1001 4096 Nov 17 20:43 src
drwxrwxr-x 1 1001 1001 4096 Nov 17 20:44 vendor
drwxrwxr-x 1 1001 1001 4096 Nov 20 13:44 web
我怎樣才能解決這個問題呢? 命令chown和setfacl不工作...
可以確認問題,具體考慮它的docker。 有類似的問題,沒有流浪。基本上我使用docker卷在我的本地磁盤上使用代碼,並使用容器中的nginx和php-fpm運行它。 我的想法是,與我第一次認爲在NTFS捲上的數據沒有任何區別,我將它移到了ext4卷中,並使用了 'chown -R nginx:nginx/var/www' 和 'chmod -R 0777/var/www/project/var/cache' 但是,即使nginx擁有並且擁有所有文件的權限,仍然給我帶來同樣的錯誤。 – WiR3D 2014-11-21 11:33:30
對不起,很久沒有答覆......很多工作。我找到了解決方案, 但不確定它是否正確。你說得對嗎,這些問題是碼頭專員。我遲到了。 – 2014-11-21 12:39:47
請做我堅持這個,它非常非常重要,它已經2天了。 – WiR3D 2014-11-21 14:37:06