Error: Starting container process caused "exec: "/Docker-entrypoint.sh ": permission denied"

Asked

Viewed 2,036 times

0

I’m getting an error when giving the build on Docker-Compose:

ERROR: for indicaaquicombrold_mysqld_1  Cannot start service mysqld: oci runtime error: container_linux.go:247: starting container process caused "exec: \"/docker-entrypoint.sh\": permission denied"


ERROR: for mysqld  Cannot start service mysqld: oci runtime error: container_linux.go:247: starting container process caused "exec: \"/docker-entrypoint.sh\": permission denied"

ERROR: Encountered errors while bringing up the project.

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 <[email protected]>

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"]

Help me solve this problem! Please. Any idea?

  • 1

    I got it solved! I gave permission chmod 755 for the file /Docker-entrypoint.sh. But now I got a new error: apache2: Syntax error on line 225 of /etc/apache2/apache2.conf: Could not open Configuration file /etc/apache2/sites-enabled/000-default.conf: Permission denied

1 answer

1

The mistake permission denied probably means your file docker-entrypoint.sh is without read and/or run permissions.

The three basic permissions for files are:

  • (R) Reading: Ensures permission to read the contents of a file
  • (W) Writing: Allows changing the contents of a file
  • (X) Execution: Allows the execution of a file if these are programs (files that are not programs ideally should not have run permissions)

See the permissions of your docker-entrypoint.sh and ensure read and run permissions:

$ ls -l docker-entrypoint.sh 
-r-xr-xr-x 1 user user 25 set 17 10:33 docker-entrypoint.sh

Use the chmod for adjust permissions as necessary:

  • chmod +r docker-entrypoint.sh for read permissions
  • chmod +x docker-entrypoint.sh for execution permissions

Browser other questions tagged

You are not signed in. Login or sign up in order to post.