错误:启动容器进程导致“ exec:\” / docker-entrypoint.sh \”:权限被拒绝”

时间:2019-01-23 22:28:50

标签: docker docker-compose dockerfile

人们

我正在尝试构建docker-compose,但出现此错误:

错误:针对indicaaquicombrold_mysqld_1无法启动服务mysqld:oci运行时错误:container_linux.go:247:启动容器进程引起“ exec:\” / docker-entrypoint.sh \”:权限被拒绝”

错误:对于mysqld无法启动服务mysqld:oci运行时错误:container_linux.go:247:启动容器进程导致“ exec:\” / docker-entrypoint.sh \”:权限被拒绝”

错误:启动项目时遇到错误。

docker-compose.yml

version: '3'

services:
  php:
    build:
      context: ./docker/php
    image: indicaaqui.com.br:tag
    volumes:
      - ./src:/var/www/html/
      - ./config/apache-config.conf:/etc/apache2/sites-enabled/000-default.conf
    ports:
      - "80:80"
      - "443:443"

  mysqld: 
    build:
      context: ./docker/mysql
    environment:
      - MYSQL_DATABASE=db_indicaaqui
      - MYSQL_USER=indicaqui
      - MYSQL_PASSWORD=secret
      - MYSQL_ROOT_PASSWORD=docker      
    volumes:
      - ./config/docker-entrypoint.sh:/docker-entrypoint.sh
      - ./database/db_indicaaqui.sql:/docker-entrypoint-initdb.d/db_indicaaqui.sql

Dockerfile(php)

FROM php:5.6-apache

MAINTAINER Limup <limup@outlook.com>

CMD [ "php" ]

RUN docker-php-ext-install pdo_mysql

# Enable apache mods.
# RUN a2enmod php5.6
RUN a2enmod rewrite


# Expose apache. 
EXPOSE 80
EXPOSE 443

# Use the default production configuration
# RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

# Override with custom opcache settings
# COPY ./../../config/php.ini $PHP_INI_DIR/conf.d/

# Manually set up the apache environment variables
 ENV APACHE_RUN_USER www-data
 ENV APACHE_RUN_GROUP www-data
 ENV APACHE_LOG_DIR /var/log/apache2
 ENV APACHE_LOCK_DIR /var/lock/apache2
 ENV APACHE_PID_FILE /var/run/apache2.pid

# Update the PHP.ini file, enable <? ?> tags and quieten logging.
RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" "$PHP_INI_DIR/php.ini"
RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" "$PHP_INI_DIR/php.ini"

RUN a2dissite 000-default.conf 
RUN chmod -R 777 /etc/apache2/sites-enabled/

WORKDIR /var/www/html/

# By default start up apache in the foreground, override with /bin/bash for interative.
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]

Dockerfile(Mysql)

FROM mariadb:latest

RUN chmod -R 777 /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]

EXPOSE 3306
CMD ["mysqld"]

帮助我解决此问题!请。 有什么主意吗?

4 个答案:

答案 0 :(得分:1)

这很可能是config/docker-entrypoint.sh上的Linux文件权限问题。如果您的主机是Linux / Mac,则可以运行:

chmod 755 config/docker-entrypoint.sh

有关Linux权限的更多信息,这是一篇有用的文章:https://www.linux.com/learn/understanding-linux-file-permissions

答案 1 :(得分:0)

首先,您需要将entrypoint.sh文件复制到其他目录而不是源代码(例如/home/entrypoint.sh),然后授予执行入口点脚本的权限:

RUN ["chmod", "+x", "/home/entrypoint.sh"]

答案 2 :(得分:0)

解决方案

$token = JWT::encode($tokenPayload, getenv("JWT_SECRET"));

$useHttps = true;

setcookie("token ", $token , $expireTime, "", "localhost:8000", $useHttps, true);

信息

  1. USER 指令设置运行映像时使用的用户名(或UID)以及可选的用户组(或GID),以及随后的任何RUN,CMD和ENTRYPOINT指令放在Dockerfile中。

  2. WORKDIR 指令为Dockerfile中跟在其后的所有RUN,CMD,ENTRYPOINT,COPY和ADD指令设置工作目录。如果WORKDIR不存在,即使以后的Dockerfile指令中未使用它,也将创建它。

链接

chown command

docker builder reference

答案 3 :(得分:0)

如果没有任何效果,一个非常常见的解决方案是重新安装 Docker .. 这就是我尝试了大约 5 个小时后,在权限等方面的所有事情后最终对我有用的方法。