Docker Container exited with Error: /init.sh: not found - docker

After creating my image and build the containers, my web container give's me that Error:
none
/usr/local/bin/docker-php-entrypoint: 9: exec: /init.sh: not found
Thats my Dockerfile:
FROM php:7.1-apache
RUN apt-get update && apt-get install -y \
libpq-dev \
libzip-dev \
libicu-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libwebp-dev \
git \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ \
--with-jpeg-dir=/usr/include/ \
--with-png-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install pdo \
&& docker-php-ext-install pdo_mysql \
&& docker-php-ext-install mysqli \
&& docker-php-ext-install intl \
&& docker-php-ext-install zip \
&& rm -rf /var/lib/apt/lists/*
# apache
RUN a2enmod rewrite
# Volume
VOLUME ["/var/www/html"]
# Clean Up
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/www/html/.git
# Init
COPY /init.sh /init.sh
RUN chmod +x /init.sh
CMD ["/init.sh"]
What am i doing wrong ?

Related

Visual studio code devcontainer error reading from server: EOF

I'm trying to do a devcontainer setup with vscode on linux (fedora 37) but I always get the error you can see in the image link below
failed to receive status: rpc error: code = Unavailable desc = error reading from server: EOF
These are my configuration files:
Dockerfile:
FROM php:7.4-apache
RUN apt-get update && apt-get install -y \
git \
unzip \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
libicu-dev \
libc-client-dev \
libkrb5-dev \
libmagickwand-dev && \
docker-php-ext-configure gd --with-freetype --with-jpeg=/usr/include/ --enable-gd && \
docker-php-ext-install -j$(nproc) gd && \
docker-php-ext-configure intl && \
PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \
docker-php-ext-install -j$(nproc) imap && \
docker-php-ext-install zip && \
docker-php-ext-install mysqli && \
docker-php-ext-install pdo_mysql && \
docker-php-ext-install intl && \
docker-php-ext-install calendar && \
docker-php-ext-install exif && \
docker-php-ext-install gettext && \
docker-php-ext-install sockets && \
yes '' | pecl install imagick && docker-php-ext-enable imagick && \
a2enmod rewrite && \
a2enmod headers && \
a2enmod cgi && \
a2enmod proxy_fcgi && \
apt-get remove -y libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
libicu-dev \
libc-client-dev \
libkrb5-dev \
libmagickwand-dev && \
apt-get clean -y
RUN sed -i -e '/.* rights="none".*pattern="PDF"/s/ rights="none"/ rights="read|write"/g' /etc/ImageMagick-6/policy.xml
COPY --from=composer:2.5 /usr/bin/composer /usr/bin/composer
devcontainer.json:
{
"name": "PHP",
"build": {
"context": ".",
"dockerfile": "Dockerfile"
},
"forwardPorts": [ "8000:80" ],
"customizations": {
"vscode": {
"extensions": [
"donjayamanne.git-extension-pack",
"waderyan.gitblame",
"ms-azuretools.vscode-docker",
"p1c2u.docker-compose",
"ms-vscode-remote.remote-ssh",
"TabNine.tabnine-vscode",
"DEVSENSE.phptools-vscode",
"xdebug.php-pack"
]
}
},
"workspaceMount":"source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
"workspaceFolder": "/workspace",
}
Thank you very much for the help
The information I found on the internet says that the problem is docker, but docker is fine.
I run my docker build and it finishes successfully, but devconteiner throws the error every time
This is most likely related to a bug in Docker stack, introduced in recent Docker 23 (check your version to make sure the below applies to you).
VSC issue: https://github.com/microsoft/vscode-remote-release/issues/7958. There you can find a workaround and links to upstream trackers that deal with the issue directly.
I can confirm the workaround of disabling BUILDKIT_INLINE_CACHE works, that is setting the following in .devcontainer.json allows for VSC to start:
{
"build": {
"args": {
"BUILDKIT_INLINE_CACHE": "0"
}
}
}
The issue itself is supposed to be fixed already, but may not have landed in your distribution yet.

Entrypoint at portainer.io is not working like in Docker image

I have a docker Image with the following Entrypoint.
ENTRYPOINT [ "sh", "-c", "/var/www/html/app/Console/cake schema update -y && /var/www/html/app/Console/cake migration && apache2-foreground"]
Now I want to use portainer.io to manage docker swarm. I created a new service to where I want to set the entrypoint (instead of in the Image). So I deleted the entrypoint In the dockerfile, and added it into "Image" > "Entrypoint". I added:
sh -c /var/www/html/app/Console/cake schema update -y && /var/www/html/app/Console/cake migration && apache2-foreground
However, the containers of the service are failing to start. Without the entrypoint, the containers are starting. Here is an example of the Dockerfile, where the Entrypoint is set.
#start with base Image from php
FROM php:7.3-apache
#install system dependencies and enable PHP modules
RUN apt-get update && apt-get install -y \
libicu-dev \
libpq-dev \
libmcrypt-dev \
mysql-client \
git \
zip \
unzip \
libzip-dev \
&& docker-php-ext-configure zip --with-libzip \
&& docker-php-ext-install zip \
&& rm -r /var/lib/apt/lists/* \
&& docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \
&& docker-php-ext-install \
intl \
mbstring \
pcntl \
pdo_mysql \
pdo_pgsql \
pgsql \
opcache \
gettext
# zip \
# mcrypt \
#configure imap for mails
RUN apt-get update && \
apt-get install -y \
libc-client-dev libkrb5-dev && \
rm -r /var/lib/apt/lists/*
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \
docker-php-ext-install -j$(nproc) imap
#install mcrypt
RUN apt-get update \
&& apt-get install -y libmcrypt-dev \
&& rm -rf /var/lib/apt/lists/* \
&& pecl install mcrypt-1.0.2 \
&& docker-php-ext-enable mcrypt
#install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
#change uid and gid of apache to docker user uid/gid
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data
# enable apache module rewrite
RUN a2enmod rewrite
#change ownership of our applications
RUN chown -R www-data:www-data /var/www/html
#Copy file to start schema update on startup
ENTRYPOINT [ "sh", "-c", "/var/www/html/app/Console/cake schema update -y && /var/www/html/app/Console/cake migration && apache2-foreground"]
EXPOSE 80
How do I have to set the Entrypoint? When I set it a portainer, it is later shown under the section CDM.

Under docker error Call to undefined function Intervention\Image\Gd\imagecreatefromjpeg

I try to install my laravel 5.7.19 application under docker(version: '3.1', ) and running some pages I got error:
Call to undefined function Intervention\Image\Gd\imagecreatefromjpeg()
I include jpeg support in web/Dockerfile.yml:
FROM php:7.2-apache
RUN apt-get update -y && apt-get install -y libpng-dev libjpeg-dev libxpm-dev libfreetype6-dev nano \
&& docker-php-ext-configure gd \
--with-freetype-dir=/usr/include/ \
--with-jpeg-dir=/usr/include/ \
--with-xpm-dir=/usr/include/ \
--with-vpx-dir=/usr/include/
RUN docker-php-ext-install \
pdo_mysql \
&& a2enmod \
rewrite
RUN docker-php-ext-install gd
But I have the same error anyway. Is path “/usr/include/” valid and how to check it ?
My working OS is Kubuntu 18...
Thanks!
You need to add into Dockerfile.yml file including of gd and types format like :
FROM php:7.2-apache
RUN apt-get update && \
apt-get install -y \
libfreetype6-dev \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev \
nano \
libgmp-dev \
libldap2-dev \
netcat \
sqlite3 \
libsqlite3-dev && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install gd pdo pdo_mysql pdo_sqlite zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite
That must help.

Dockerfile drupal console access denied mkdir

I'm trying to install drupal console in docker (under Linux Antergos). I've the following error :
Warning: mkdir(): Permission denied in phar:///usr/local/bin/drupal/vendor/drupal/console-core/src/Utils/ConfigurationManager.php on line 49
Here is my PHP dockerfile :
FROM php:7.0-fpm
RUN usermod -u 1000 www-data
# Set timezone
RUN rm /etc/localtime
RUN ln -s /usr/share/zoneinfo/Europe/Bruxelles /etc/localtime
RUN "date"
RUN apt-get update && apt-get install -y \
git \
unzip \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
mysql-client \
&& docker-php-ext-install -j$(nproc) iconv mcrypt \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install mysqli pdo pdo_mysql mcrypt zip mbstring opcache json
# Install Xdebug / Redis
RUN pecl install redis \
&& pecl install xdebug \
&& docker-php-ext-enable redis xdebug
# Set the Drush version.
ENV DRUSH_VERSION 8.1.2
# Install Drush 8 with the phar file.
RUN curl -fsSL -o /usr/local/bin/drush "https://github.com/drush-ops/drush/releases/download/$DRUSH_VERSION/drush.phar" && \
chmod +x /usr/local/bin/drush
# Download console.
RUN curl https://drupalconsole.com/installer -L -o drupal.phar
# Install console.
RUN mv drupal.phar /usr/local/bin/drupal && \
chmod +x /usr/local/bin/drupal && \
drupal init --override
# Create drush-backups dir
RUN mkdir /var/www/drush-backups/
USER 1000
WORKDIR /var/www/html
To solve the problem I had to install Drupal Console by composer. There is certainly another solution, but it's work with it.

Install PHP7 fpm and memcached with Docker

I have an app with Docker, and I am trying to install memcached with php7-fpm.
According to official docker documentation I have in my Dockerfile:
# PHP Version
FROM php:7.0-fpm
...
# Install Memcached
RUN apt-get install -y libmemcached-dev && \
pecl install memcached && \
docker-php-ext-enable memcached
But I got this error:
pecl/memcached requires PHP (version >= 5.2.0, version <= 6.0.0, excluded versions: 6.0.0), installed version is 7.0.9
I don't want to switch to PHP 5.6. Any ideas?
We build the memcache extension from scratch when building our php7 container. Maybe our approached helps you or points you to the right direction. The documentation in the Dockerhub really seems to be faulty, tried pecl and it didn't work here either.
So this is how it looks in our Dockerfile:
RUN apt-get update && apt-get install -y
libmemcached11 \
libmemcachedutil2 \
libmemcached-dev \
libz-dev \
git \
&& cd /root \
&& git clone -b php7 https://github.com/php-memcached-dev/php-memcached \
&& cd php-memcached \
&& phpize \
&& ./configure \
&& make \
&& make install \
&& cd .. \
&& rm -rf php-memcached \
&& echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini \
&& apt-get remove -y build-essential libmemcached-dev libz-dev \
&& apt-get remove -y libmemcached-dev libz-dev \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
It seems that the memcached is incompatible with php7 and need another way to install it.
After a quick lock at Laradock repo I solved in this manner, I post the code:
# PHP Version
FROM php:7.0-fpm
# Install the PHP extensions we need
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
libmemcached-dev \
libz-dev \
libpq-dev \
libjpeg-dev \
libpng12-dev \
libfreetype6-dev \
libicu-dev \
libssl-dev \
libmcrypt-dev && \
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr && \
docker-php-ext-install gd mysqli opcache intl
.....
# Install Memcached
RUN curl -L -o /tmp/memcached.tar.gz "https://github.com/php-memcached- dev/php-memcached/archive/php7.tar.gz" && \
mkdir -p memcached && \
tar -C memcached -zxvf /tmp/memcached.tar.gz --strip 1 && \
( \
cd memcached && \
phpize && \
./configure && \
make -j$(nproc) && \
make install \
) && \
rm -r memcached && \
rm /tmp/memcached.tar.gz && \
docker-php-ext-enable memcached
one more solution
FROM php:7.2-fpm
# ...
# INSTALL memcached
RUN apt-get upgrade -y
RUN apt-get install -y memcached
RUN apt-get install -y libmemcached-dev zlib1g-dev libicu-dev
RUN git clone -b php7 https://github.com/php-memcached-dev/php-memcached
/usr/src/php/ext/memcached \
&& docker-php-ext-configure /usr/src/php/ext/memcached \
--disable-memcached-sasl \
&& docker-php-ext-install /usr/src/php/ext/memcached \
&& rm -rf /usr/src/php/ext/memcached

Resources