Visual studio code devcontainer error reading from server: EOF - docker

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.

Related

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

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 ?

Docker: Build fail on another host with same configuration

I'm using Docker in a developement environment. I have two pc, both with same OS (kubuntu 20.04) and same docker version.
In one the dockerfile build without errors, in the other fails with
$ docker build -t letsjump/mydockername -f docker-data/webserver73/Dockerfile .
#...lot of compile output...
configure: error: unrecognized options: --with-freetype, --with-jpeg, --with-freetype, --with-webp
The command '/bin/sh -c curl -sL https://deb.nodesource.com/setup_12.x | bash - && apt-key update && DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" install $CUSTOM_BUILD_DEPS $PHPIZE_DEPS sendmail git mariadb-client openssh-client nano netcat linkchecker nodejs build-essential libzip-dev libz-dev wget unixodbc odbcinst unixodbc-dev gnupg libwebp-dev libonig-dev --no-install-recommends && npm -g install npm#latest && docker-php-ext-configure gd --with-freetype --with-jpeg --with-freetype --with-webp && docker-php-ext-configure bcmath && docker-php-ext-configure calendar && docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr && docker-php-ext-install gd intl pdo_mysql mysqli mbstring opcache zip bcmath calendar soap && pecl install memcached-3.1.5 && echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini && printf "\n" | pecl -d preferred_state=beta install xdebug' returned a non-zero code: 1
In both hosts I have the same OS (kubuntu 20.04 desktop) and almost the same Docker version.
In this host the dockerfile build succesfully:
$ docker --version
Docker version 19.03.5, build 633a0ea838
In this other not:
$ docker --version
Docker version 19.03.12, build 48a66213fe
This is the dockerfile:
# Dockerfile (c) letsjump 2018
FROM php:7.3-apache
MAINTAINER letsjump <letsjump#xxx>
WORKDIR /
COPY ./docker-data/webserver73/ /
RUN chown -R "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "/usr/local/bin";
RUN chmod -R +xr "/usr/local/bin/";
EXPOSE 80
EXPOSE 443
RUN useradd -ms /dev/null dbmaker
RUN chown -R dbmaker:dbmaker /home/dbmaker
# define build dependency lists
# inherited from PHP base image:
# PHPIZE_DEPS=autoconf dpkg-dev file g++ gcc libc-dev libpcre3-dev make pkg-config re2c
ENV CUSTOM_BUILD_DEPS \
unzip \
libmemcached-dev \
libicu-dev \
libfreetype6-dev \
libjpeg-dev \
libjpeg62-turbo-dev \
libxml2-dev \
zlib1g-dev \
libpng-dev
# list of other packages which could be deinstalled at the end
ENV CUSTOM_REMOVE_LIST cpp \
cpp-4.9 \
g++-4.9 \
gcc-4.9 \
libgcc-4.9-dev \
libhashkit-dev \
libsasl2-dev \
libstdc++-4.9-dev
RUN apt-get update && apt-get install -my gnupg
# Install system packages for PHP extensions recommended for Yii 2.0 Framework
# Install PHP extensions required for Yii 2.0 Framework
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
apt-key update && \
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" install \
$CUSTOM_BUILD_DEPS \
$PHPIZE_DEPS \
sendmail \
git \
mariadb-client \
openssh-client \
nano \
netcat \
linkchecker \
nodejs \
build-essential \
libzip-dev \
libz-dev \
wget \
unixodbc \
odbcinst \
unixodbc-dev \
gnupg \
libwebp-dev \
libonig-dev \
--no-install-recommends && \
npm -g install npm#latest && \
docker-php-ext-configure gd --with-freetype --with-jpeg --with-freetype --with-webp && \
docker-php-ext-configure bcmath && \
docker-php-ext-configure calendar && \
docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr && \
docker-php-ext-install gd \
intl \
pdo_mysql \
mysqli \
mbstring \
opcache \
zip \
bcmath \
calendar \
soap && \
# printf "\n" | pecl -d preferred_state=beta install xdebug
pecl install memcached-3.1.5 && \
echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini && \
printf "\n" | pecl -d preferred_state=beta install xdebug
# apt-get remove -y $PHPIZE_DEPS $CUSTOM_BUILD_DEPS $CUSTOM_REMOVE_LIST && \
# dpkg --purge $(dpkg -l | awk '/^rc/ { print $2 }') && \
# apt-get clean && \
# rm -rf /usr/src/php* && \
# rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
#set -x \
# && cd /usr/src/php/ext/odbc \
# && phpize \
# && sed -ri 's#^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$##&#g' configure \
# odbc
# docker-php-ext-configure odbc --with-unixODBC=/usr --with-dbmaker=/home/dbmaker/5.2 && \
# docker-php-ext-configure odbc --with-unixODBC=/usr --with-dbmaker=/home/dbmaker/5.2 --with-adabas=no && \
# Install less-compiler
RUN npm install -g \
less \
lesshint \
uglify-js \
uglifycss
ENV PHP_USER_ID=33 \
PHP_ENABLE_XDEBUG=1 \
VERSION_COMPOSER_ASSET_PLUGIN=^1.4.6 \
VERSION_PRESTISSIMO_PLUGIN=^0.3.10 \
PATH=/var/www/:/root/.composer/vendor/bin:$PATH \
TERM=linux \
COMPOSER_ALLOW_SUPERUSER=1 \
GITHUB_API_TOKEN=${GITHUB_API_TOKEN}
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- \
--install-dir=/usr/local/bin \
--filename=composer --version=1.10.16 && \
composer global require --optimize-autoloader \
"fxp/composer-asset-plugin:${VERSION_COMPOSER_ASSET_PLUGIN}" \
"hirak/prestissimo:${VERSION_PRESTISSIMO_PLUGIN}" && \
composer global dumpautoload --optimize && \
composer clear-cache
RUN chown -R 1000:33 /var/www
# Install Yii framework bash autocompletion
RUN curl -L https://raw.githubusercontent.com/yiisoft/yii2/master/contrib/completion/bash/yii \
-o /etc/bash_completion.d/yii
# enabling specific apache2 modules
# enabling specific apache2 modules
RUN a2enmod rewrite && \
service apache2 restart
WORKDIR /var/www
Yes, the dockerfile is probably a mess, with a lot of adds on the fly. But why it compiles in one host and in the other not?
UPDATE
After reading the reasonable answer of aankhen, I emptied the docker-data/webserver73 folder which in any case did not contain any relevant code except one apache virtualhost and one xdebug.ini configuration file in their relative folders.
The build failed again with the same error as above.
I also want to point out that the wevserver73 folder contains the exact same files as the one on the other host with the same owner and rights.
I would expect failures to happen sporadically and periodically with this dockerfile. Why? Because you haven't pinned the versions of the majority of tools you're installing. You implicitly install the latest version of a bunch of GNU/Linux libraries and then explicitly install the latest version of npm and you follow this up by using npm to install the latest version of a bunch of javascript modules. I can see that you pin the versions of some libs, but to guarantee repeatability you have to pin everything.
Also, as #Aankhen said in the comments, you also have a copy command that is copying files from the local filesystem, which could contain anything and again is unlikely to result in a portable repeatable image.
The solution to this is a) pin everything, or b) use a registry to share an image that has been built once and rely on a pinned version of that. Generally, banks and large corporations require the pinning solution, and less regulated industries often go with the registry solution.
I answer to my question:
As Software-engineer said in his answer, pin, pin, pin.
In this case it was the PHP's mantainers (questionable) choice to change the Debian release within a minor version of the docker image (php:7.3-apache). Here they switched from stretch to buster.
So the new pulled php:7.3-apache image had a completely different OS and different dependent library and behaviors.
So, as Software-engineer said, the right and the fastest solution to this problem is to pin the PHP image to a tag related to the distribution: php:7.3-apache-stretch.
The slower and unstable solution, in case you want to use the unpinned version, is to adapt the GD configure options to the new release:
...
docker-php-ext-configure gd --with-gd --with-webp-dir --with-jpeg-dir \
--with-png-dir --with-zlib-dir --with-freetype-dir && \
...
taking care to include the necessary libraries first: libfreetype6-dev, libjpeg-dev and libjpeg62-turbo-dev
But this will require a manual pull from the server for any host that has a non recent build of the same image.

gulp imagimine plugin throwinf error while optimizing images

I have such a gulp task
gulp.task('images', () => {
return gulp.src('assets/images/**/*')
.pipe($.cache($.imagemin()))
.pipe(gulp.dest('public/build/images'));
});
and it throwing error in this line .pipe($.cache($.imagemin())) for me:
events.js:167
throw er; // Unhandled 'error' event
^
Error: write callback called multiple times
at DestroyableTransform.afterTransform (/var/www/vhosts/devgenix/node_modules/readable-stream/lib/_stream_transform.js:84:31)
at EventEmitter.signals.on.err (/var/www/vhosts/devgenix/node_modules/gulp-cache/lib/index.js:451:7)
at EventEmitter.emit (events.js:182:13)
at DestroyableTransform.onError (/var/www/vhosts/devgenix/node_modules/gulp-cache/lib/index.js:288:15)
at Object.onceWrapper (events.js:273:13)
at DestroyableTransform.emit (events.js:187:15)
at Immediate.<anonymous> (/var/www/vhosts/devgenix/node_modules/through2-concurrent/through2-concurrent.js:37:14)
at runCallback (timers.js:706:11)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
but for other developers on their machines, all works fine.
I'm running all the code under the custom alpine docker container with preinstalled node (other devs no), so maybe it's an issue and I just need to install some missing dependency but I can't figure out what is wrong.
My docker file is actually for PHP with the node, here is the docker file content:
FROM php:7.1-fpm-alpine
ENV ZMQ_VERSION 4.3.1
ENV BUILD_DEPS autoconf file gcc libc-dev make g++ pkgconf re2c git
RUN apk add --update --no-cache --virtual .build-deps $BUILD_DEPS
# Error code: 127
RUN apk add --no-cache --virtual .php-build-deps \
nasm \
libsodium \
freetype-dev \
libmcrypt-dev \
postgresql-dev \
libxml2-dev \
zlib-dev cyrus-sasl-dev libmemcached-dev \
# the next line is for node and npm packages (node-sass requires python/make/g++ to build something)
python \
&& apk add --update nodejs nodejs-npm \
# for GD
bash \
freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev \
# just good to have installed
ca-certificates wget \
## Install git (we'll never delete it)
#&& apk add --no-cache git \
&& docker-php-ext-configure gd \
--with-gd \
--with-freetype-dir=/usr/include/ \
--with-png-dir=/usr/include/ \
--with-jpeg-dir=/usr/include/ \
&& NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) \
## Installable modules
&& docker-php-ext-install -j${NPROC} iconv mcrypt bcmath pdo_mysql opcache pgsql pdo_pgsql soap pcntl exif zip gd \
&& apk del --no-cache freetype-dev libpng-dev libjpeg-turbo-dev \
## Memcached
&& git clone https://github.com/php-memcached-dev/php-memcached.git \
&& cd php-memcached \
&& git checkout php7 \
&& phpize \
&& ./configure --disable-memcached-sasl \
&& make \
&& cp modules/memcached.so $(php-config --extension-dir) \
&& docker-php-ext-enable memcached \
## Composer
&& cd ~ \
&& curl -sS https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer \
## Gulp
&& npm install -g gulp \
## Cleanup
&& rm -rf /var/cache/apk/*
RUN docker-php-ext-configure calendar && docker-php-ext-install calendar
ADD www.conf /usr/local/etc/php-fpm.d
ADD php-fpm.conf /usr/local/etc
ADD php.ini /usr/local/etc/php/
WORKDIR /var/www/vhosts/devgenix/
#EXPOSE 22
CMD ["php-fpm", "--fpm-config", "/usr/local/etc/php-fpm.conf"]
Maybe someone has any ideas why it's not working for me? Thanks!
updated
npm version: 6.4.1
gulp version: 3.9.1
gulp-imagemin version: 4.1.0
I solve the issue by adding libjpeg-turbo libjpeg-turbo-dev libpng libpng-dev automake dependencies to my docker file

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.

Resources