我有以下泊塢窗文件:無法泊塢窗內啓動tomcat:「權限被拒絕」
FROM debian:jessie
RUN apt-get update && apt-get install -y wget
RUN wget --quiet http://www.us.apache.org/dist/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.tar.gz -O /tmp/tomcat.tar.gz
RUN cd /tmp && tar xf tomcat.tar.gz
RUN mv /tmp/apache-tomcat-8.5.20 /usr/share/
RUN adduser --system --shell /bin/bash --gecos 'Tomcat Java Servlet and JSP engine' --group --disabled-password --home /home/tomcat tomcat
RUN chown -R tomcat:tomcat /usr/share/apache-tomcat-8.5.20/*
RUN chmod +x /usr/share/apache-tomcat-8.5.20/bin/*.sh
RUN apt-get update && apt-get install -y openjdk-7-jre-headless
CMD ["/bin/bash"]
如果我編譯這對我的筆記本電腦與Ubuntu 17.04和泊塢窗1.12.6,構建78d1802,我可以執行
su tomcat -c /usr/share/apache-tomcat-8.5.20/bin/startup.sh
沒有任何問題:
$ sudo docker run -it ff1323fadc66
[email protected]:/# su tomcat -c /usr/share/apache-tomcat-8.5.20/bin/startup.sh
Using CATALINA_BASE: /usr/share/apache-tomcat-8.5.20
Using CATALINA_HOME: /usr/share/apache-tomcat-8.5.20
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-8.5.20/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/share/apache-tomcat-8.5.20/bin/bootstrap.jar:/usr/share/apache-tomcat-8.5.20/bin/tomcat-juli.jar
Tomcat started.
但是,如果我嘗試同樣在Ubuntu 16.04 LTS與泊塢窗1.12.6,構建78d1802,它在AWS上託管,我得到以下輸出:
$ sudo docker run -it 96e0e82a9dda
[email protected]:/# su tomcat -c /usr/share/apache-tomcat-8.5.20/bin/startup.sh
Using CATALINA_BASE: /usr/share/apache-tomcat-8.5.20
Using CATALINA_HOME: /usr/share/apache-tomcat-8.5.20
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-8.5.20/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/share/apache-tomcat-8.5.20/bin/bootstrap.jar:/usr/share/apache-tomcat-8.5.20/bin/tomcat-juli.jar
touch: cannot touch '/usr/share/apache-tomcat-8.5.20/logs/catalina.out': Permission denied
/usr/share/apache-tomcat-8.5.20/bin/catalina.sh: 434: /usr/share/apache-tomcat-8.5.20/bin/catalina.sh: cannot create /usr/share/apache-tomcat-8.5.20/logs/catalina.out: Permission denied
這怎麼可能?碼頭文件不應該產生相同的環境?我也在MacOS上嘗試過它,它也像魅力一樣在那裏啓動tomcat。
我已經試圖繞過這個chmod 777 /usr/share/apache-tomcat-8.5.20/logs/
,但它也沒有工作。
編輯:
按照要求的ls -alh /usr/share/apache-tomcat-8.5.20/logs/
[email protected]:/# su tomcat -c /usr/share/apache-tomcat-8.5.20/bin/startup.sh
Using CATALINA_BASE: /usr/share/apache-tomcat-8.5.20
Using CATALINA_HOME: /usr/share/apache-tomcat-8.5.20
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-8.5.20/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/share/apache-tomcat-8.5.20/bin/bootstrap.jar:/usr/share/apache-tomcat-8.5.20/bin/tomcat-juli.jar
touch: cannot touch '/usr/share/apache-tomcat-8.5.20/logs/catalina.out': Permission denied
/usr/share/apache-tomcat-8.5.20/bin/catalina.sh: 434: /usr/share/apache-tomcat-8.5.20/bin/catalina.sh: cannot create /usr/share/apache-tomcat-8.5.20/logs/catalina.out: Permission denied
[email protected]:/# ls -alh /usr/share/apache-tomcat-8.5.20/logs/
total 8.0K
drwxr-x--- 2 tomcat tomcat 4.0K Aug 2 21:35 .
drwxr-xr-x 17 root root 4.0K Sep 6 06:58 ..
[email protected]:/#
而且輸出:當然有可能,而無需切換用戶啓動tomcat,然後用根,但我寧願要避免這種情況。
EDIT2:
的主機是Ubuntu的LTS 16.04.3:
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.3 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.3 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
它也有一個開發日誌:
$ ls -l /run/systemd/journal/dev-log
srw-rw-rw- 1 root root 0 Sep 5 13:13 /run/systemd/journal/dev-log
試運行'chmod -R 777在/ usr /共享/ Apache的Tomcat的20年5月8日/日誌/' –
我這樣做的很好,但我沒有工作。無論如何,編譯圖像後目錄是空的。 – mistapink
嘗試使用upstart命令啓動它:'service tomcat start'或者'/ etc/init.d/tomcat'腳本 –