1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【docker】ERROR:OCI runtime create failedが出る。

Posted at

###状況

Dockerfile
FROM php:7.3-fpm
COPY php.ini /usr/local/etc/php/

RUN apt-get update \
  && apt-get install -y zlib1g-dev libzip-dev mariadb-client \
  && docker-php-ext-install zip pdo_mysql

#Composer install
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
RUN php composer-setup.php
RUN php -r "unlink('composer-setup.php');"
RUN mv composer.phar /usr/local/bin/composer

ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_HOME /composer
ENV PATH $PATH:/composer/vendor/bin

RUN composer global require "laravel/installer"

php:7.3-fpmのDockerfile下のように書き、docker-compose up -d --buildすると、次のようなエラーが出る。

ERROR: for php-fpm  Cannot start service php-fpm: OCI runtime create failed: container_linux.go:344: starting container process caused "chdir to cwd (\"/var/www/html\") set in config.json failed: permission denied": unknown
ERROR: Encountered errors while bringing up the project.

chdir to cwd (\"/var/www/html\")などを見るとphp-fpmの作業ディレクトリの問題だろうと思いDockerfileを修正する。

Dockerfile
WORKDIR /var/www 

今回はアプリを/var/wwwに置いているので、そこを作業ディレクトリに指定してみる。
再びdocker-compose up -dしてみると無事コンテナが起動する。

###原因
単純にDockerfileに作業ディレクトリの指定がなく、/var/www/htmlとなっていたこと。
なぜ/var/www/htmlとなっていたかはわからない。デフォルトではそうなるのだろうか。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?