Docker Community Forums

Share and learn in the Docker community.

Error when starting php:apache5-6 container


(Troyrudolph) #1

I cannot get my apache/php container to start on Docker for Windows. It builds fine, but will not start properly

ERROR: for manager_web Cannot start service web: OCI runtime create failed: container_linux.go:296: starting container process caused “process_linux.go:398: container init caused “mkdir /var/www/html: file exists””: unknown

In our Dockerfile, for “php:5.6-apache”, we have a command to map the Document Root to our application location.

“RUN rm -rf /var/www/html; ln -s /www/public /var/www/html”

Building the container works fine but when I try to start it, it fails with the error shown below. Version and detailed log of the error are show below. Also, the Docker file is pasted below as well.

Any ideas on how to fix this?

Thank you

$ docker version
Client:
Version: 17.12.0-ce
API version: 1.35
Go version: go1.9.2
Git commit: c97c6d6
Built: Wed Dec 27 20:05:22 2017
OS/Arch: windows/amd64

Server:
Engine:
Version: 17.12.0-ce
API version: 1.35 (minimum version 1.12)
Go version: go1.9.2
Git commit: c97c6d6
Built: Wed Dec 27 20:12:29 2017
OS/Arch: linux/amd64
Experimental: true

Detailed Log:

urllib3.connectionpool._make_request: http://localhost:None "POST /v1.25/containers/f8db1de318f640747f56b5dca7b49e3d557b80c1582d5d7e70dc40b04801e5ad/start HTTP/1.1" 500 197
Creating manager_web ... error
compose.parallel.parallel_execute_iter: Failed: ServiceName(project=u'docker', service='web', number=1)
compose.parallel.feed_queue: Pending: set([])

ERROR: for manager_web  Cannot start service web: OCI runtime create failed: container_linux.go:296: starting container process caused "process_linux.go:398: container init caused \"mkdir /var/www/html: file exists\"": unknown
compose.parallel.parallel_execute_iter: Failed: <Service: web>
compose.parallel.feed_queue: Pending: set([])

ERROR: for web  Cannot start service web: OCI runtime create failed: container_linux.go:296: starting container process caused "process_linux.go:398: container init caused \"mkdir /var/www/html: file exists\"": unknown
ERROR: compose.cli.main.main: Encountered errors while bringing up the project.

Dockerfile:

FROM php:5.6-apache
COPY php.ini /usr/local/etc/php/
RUN apt-get update \
  && apt-get install -y \
	libfreetype6-dev \
	libjpeg62-turbo-dev \
	libpng12-dev \
	libmcrypt-dev \
	libxslt-dev \
	libxml2-dev \
	libldap2-dev \
	unzip \
	zip \
	libwww-perl \
  && docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
  && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
  && docker-php-ext-install \
	pdo_mysql \
	mysqli \
	mbstring \
	gd \
	zip \
	iconv \
	mcrypt \
	exif \
	ldap \
	soap \
	xsl \
	wddx

# Install internationalization
RUN apt-get install -y\
    g++ \
    libicu-dev &&\
    docker-php-ext-install intl

# Enable and configure xdebug
RUN pecl install xdebug-2.5.1
RUN docker-php-ext-enable xdebug

# mysql client needed for shared_clients.pl to create databases
RUN apt-get install -y mysql-client

# Symlink public to apache root
RUN rm -rf /var/www/html; ln -s /www/public /var/www/html

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

# Enable necessary modules in Apache 2
RUN a2enmod rewrite expires mime filter deflate

# Add stuff to enable our LDAP servers
COPY ca.crt /etc/ipa/ca.crt
COPY ldap.conf /etc/ldap/ldap.conf

(Sam) #2

when you did the ln , it probably mapped to a folder root permissions as the RUN command is at build time as root.

and at container run time the application is probably executing as some other userid…

why is it trying to create /var/www/html anyhow?

 caused \"mkdir /var/www/html: file exists\"": unknown