docker-compose up -d --buildコマンドを実行すると、下記のようなエラーが発生してしまいます。
今回はlaravel用の環境構築を行いたいです。
docker-compose up -d --build Starting app_db ... error ERROR: for app_db Cannot start service mysql: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\"/host_mnt/Users/nakamura/program/laravel-portfolio/docker-config/mysql/data\\" to rootfs \\"/var/lib/docker/overlay2/3a917c4cbf950dbcc4ae9e8a0b89ab37793a104afccf898ae28930a590853404/merged\\" at \\"/var/lib/docker/overlay2/3a917c4cbf950dbcc4ae9e8a0b89ab37793a104afccf898ae28930a590853404/merged/var/lib/mysql\\" caused \\"not a directory\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type ERROR: for mysql Cannot start service mysql: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\"/host_mnt/Users/nakamura/program/laravel-portfolio/docker-config/mysql/data\\" to rootfs \\"/var/lib/docker/overlay2/3a917c4cbf950dbcc4ae9e8a0b89ab37793a104afccf898ae28930a590853404/merged\\" at \\"/var/lib/docker/overlay2/3a917c4cbf950dbcc4ae9e8a0b89ab37793a104afccf898ae28930a590853404/merged/var/lib/mysql\\" caused \\"not a directory\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type ERROR: Encountered errors while bringing up the project.
下記コードです。
docker-compose.yml
version: '3' services: web: build: ./docker-config/php container_name: app_php volumes: - ./laravel:/var/www/laravel working_dir: /var/www/laravel depends_on: - mysql nginx: image: nginx container_name: app_nginx build: ./docker-config/nginx ports: - "80:80" volumes: - .:/var/www - ./docker-config/nginx/default.conf:/etc/nginx/conf.d/default.conf depends_on: - web mysql: image: mysql:8.0 container_name: app_db ports: - 3306:3306 environment: MYSQL_DATABASE: development MYSQL_ROOT_USER: root MYSQL_ROOT_PASSWORD: root MYSQL_USER: m_user MYSQL_PASSWORD: m_user TZ: 'Asia/Tokyo' volumes: - ./docker-config/mysql/data:/var/lib/mysql - ./docker-config/mysql/my.cnf:/etc/mysql/conf.d/my.cnf depends_on: - mysql-volume mysql-volume: image: busybox volumes: - ./docker-config/mysql/data:/var/lib/mysql phpmyadmin: image: phpmyadmin/phpmyadmin container_name: app_pma environment: - PMA_ARBITRARY=1 - PMA_HOST=mysql - PMA_USER=root - PMA_PASSWORD=root links: - mysql ports: - 8080:80 volumes: - /sessions
nginx/default.conf
server { index index.php index.html; root /var/www/laravel/public; location / { root /var/www/laravel/public; try_files $uri $uri/ /index.php?$query_string; } location ~ .php$ { try_files $uri =404; fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass web:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } }
docker-config/nginx/Dockerfile
FROM alpine:3.6 # nginxのインストール RUN apk update && \ apk add --no-cache nginx RUN mkdir -p /run/nginx # RUN apk add openssl # ADD ssl /etc/nginx/ssl # フォアグラウンド CMD nginx -g "daemon off;"
php/Dockerfile
FROM php:7.2-fpm COPY php.ini /usr/local/etc/php/ # install composer RUN cd /usr/bin && curl -s http://getcomposer.org/installer | php && ln -s /usr/bin/composer.phar /usr/bin/composer # install packages RUN apt-get update \ && apt-get install -y \ gcc \ make \ libpng-dev \ git \ unzip \ vim \ libmcrypt-dev \ mariadb-client \ curl \ gnupg \ openssl \ zlib1g-dev \ && docker-php-ext-install pdo_mysql mysqli mbstring zip # install stable node and latest npm RUN curl -sL https://deb.nodesource.com/setup_10.x | bash RUN apt-get install -y nodejs # install xdebug RUN pecl install xdebug-2.7.2 && docker-php-ext-enable xdebug WORKDIR /var/www ADD . /var/www RUN chown -R www-data:www-data /var/www
php/php.ini
[Date] date.timezone = "Asia/Tokyo" [mbstring] mbstring.internal_encoding = "UTF-8" mbstring.language = "Japanese" [xdebug] xdebug.remote_enable = On xdebug.remote_port = 9001 xdebug.remote_autostart = On xdebug.remote_host = 192.168.99.1 xdebug.profiler_output_dir = "/tmp" xdebug.max_nesting_level= 1000 xdebug.idekey = "PHPSTORM"
mysql/my.cnf
# MySQLサーバーへの設定 [mysqld] character-set-server = utf8mb4 collation-server = utf8mb4_bin # タイムゾーン default-time-zone = SYSTEM log_timestamps = SYSTEM # mysql8.0用に認証変更 default-authentication-plugin = mysql_native_password # エラーログの設定 # log-error = /var/log/mysql/mysql-error.log # スロークエリログ slow_query_log = 1 slow_query_log_file = /var/log/mysql/mysql-slow.log long_query_time = 5.0 log_queries_not_using_indexes = 0 # 実行ログ general_log = 1 general_log_file = /var/log/mysql/mysql-query.log # mysqlオプションの設定 [mysql] default-character-set = utf8mb4 # mysqlクライアントツールの設定 [client] default-character-set = utf8mb4
どなたかご教授いただけると幸いでございます。
また、laravelの環境構築について知見のある方、良い記事など教えていただきたいです。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/12/08 07:36