爲開發構建Docker鏡像,我想在運行鏡像時自動啓動mysql和apache。Docker:從入口點或CMD啓動mysql和apache
如果我登錄容器並運行「service apache2 start」和「service mysql start」,它就可以工作。但是如果我放入入口點或CMD就會失敗。 我能夠通過將ENTRYPOINT ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
啓動Apache,但我無法以編程方式啓動mysql。
我嘗試了很多很多東西。大多數情況下,如果容器沒有運行,默默無聞,其他時間我得到了:docker:來自守護進程的錯誤響應:oci運行時錯誤:container_linux.go:247:啓動容器進程導致「exec:\」/ etc/init .D /啓動mysql \「:統計/etc/init.d/mysql啓動:沒有這樣的文件或目錄」
這是我到目前爲止有:
FROM debian:wheezy
RUN apt-get update && \
apt-get install -y libmcrypt-dev \
subversion ssl-cert nano wget unzip && \
echo "deb http://packages.dotdeb.org wheezy-php56 all" >> /etc/apt/sources.list.d/dotdeb.list && \
echo "deb-src http://packages.dotdeb.org wheezy-php56 all" >> /etc/apt/sources.list.d/dotdeb.list && \
wget http://www.dotdeb.org/dotdeb.gpg -O- | apt-key add - && \
echo mysql-server-5.5 mysql-server/root_password password yourpass | debconf-set-selections && \
echo mysql-server-5.5 mysql-server/root_password_again password yourpass | debconf-set-selections && \
apt-get update && \
apt-get install -y \
apache2 apache2-doc apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common libapache2-mod-php5 \
openssl php-pear php5 php5-cli php5-common php5-curl php5-gd php5-mcrypt php5-mysql php5-memcache php5-readline \
subversion ssl-cert nano wget unzip \
mysql-server-5.5 mysql-client mysql-client-5.5 mysql-common && \
/etc/init.d/mysql start && \
mysql -u root -pyourpass -e "create database mydb;" && \
rm -rf /var/lib/apt/lists/* && \
rm /etc/apache2/sites-enabled/000-default && \
mkdir -p /var/www/html && \
chown www-data:www-data -R /var/www/html/
COPY conf/etc/ /etc/
COPY mydump.sql /var/www/html/mydump.sql
RUN /etc/init.d/mysql start && \
mysql -u root -pyourpass -h localhost mydb < /var/www/html/mydump.sql && \
rm /var/www/html/mydump.sql
VOLUME ["/var/www", "/var/log/apache2", "/etc/apache2", "/var/lib/mysql"]
EXPOSE 80 443 3306
失敗,出現什麼錯誤? –
docker:來自守護進程的錯誤響應:oci運行時錯誤:container_linux.go:247:啓動容器進程導致「exec:\」/ etc/init.d/mysql start \「:stat /etc/init.d/mysql start:沒有這樣的文件或目錄「 –