Building image in minikube got stuck - docker

I'm trying to deploy local image in minikube.
This is what I'm doing:
minikube start
eval $(minikube docker-env)
Trying to build image in minikube (build image -t my-image .), but it gets stuck at 2. fetching packages... line
I don't have any HTTP_PROXY, HTTPS_PROXY, NO_PROXY set. Anybody had such an issue?
Edit. This is my Dockerfile. It works fine. I can build, push, pull from remote docker registry. It only doesn't work, when I build image in minikube.
FROM node:10.16.2-alpine
WORKDIR /app/server
ADD package.json .
RUN apk --no-cache add --virtual .build build-base python && \
yarn install && \
npm rebuild bcrypt --build-from-source && \
yarn cache clean && \
apk del .build
ADD . .
EXPOSE 3000
CMD [ "yarn", "start" ]
This is docker build log in minikube:
Sending build context to Docker daemon 292MB
Step 1/7 : FROM node:10.16.2-alpine
---> 4f877c96a193
Step 2/7 : WORKDIR /app/server
---> Using cache
---> 71cd2676c364
Step 3/7 : ADD package.json .
---> Using cache
---> af5f79d46abf
Step 4/7 : RUN apk --no-cache add --virtual .build build-base python && yarn install && npm rebuild bcrypt --build-from-source && yarn cache clean && apk del .build
---> Running in c38695ed65b7
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/27) Installing binutils (2.31.1-r2)
(2/27) Installing libmagic (5.36-r0)
(3/27) Installing file (5.36-r0)
(4/27) Installing gmp (6.1.2-r1)
(5/27) Installing isl (0.18-r0)
(6/27) Installing libgomp (8.3.0-r0)
(7/27) Installing libatomic (8.3.0-r0)
(8/27) Installing mpfr3 (3.1.5-r1)
(9/27) Installing mpc1 (1.0.3-r1)
(10/27) Installing gcc (8.3.0-r0)
(11/27) Installing musl-dev (1.1.20-r5)
(12/27) Installing libc-dev (0.7.1-r0)
(13/27) Installing g++ (8.3.0-r0)
(14/27) Installing make (4.2.1-r2)
(15/27) Installing fortify-headers (1.0-r0)
(16/27) Installing build-base (0.5-r1)
(17/27) Installing libbz2 (1.0.6-r7)
(18/27) Installing expat (2.2.7-r0)
(19/27) Installing libffi (3.2.1-r6)
(20/27) Installing gdbm (1.13-r1)
(21/27) Installing ncurses-terminfo-base (6.1_p20190105-r0)
(22/27) Installing ncurses-terminfo (6.1_p20190105-r0)
(23/27) Installing ncurses-libs (6.1_p20190105-r0)
(24/27) Installing readline (7.0.003-r1)
(25/27) Installing sqlite-libs (3.28.0-r0)
(26/27) Installing python2 (2.7.16-r1)
(27/27) Installing .build (0)
Executing busybox-1.29.3-r10.trigger
OK: 211 MiB in 43 packages
yarn install v1.17.3
info No lockfile found.
[1/4] Resolving packages...
warning bugsnag#2.4.3: All projects should upgrade to our universal JS notifier: "#bugsnag/js". See https://github.com/bugsnag/bugsnag-js/blob/master/UPGRADING.md for more details.
warning bugsnag > cuid > core-js#1.2.7: core-js#<2.6.8 is no longer maintained. Please, upgrade to core-js#3 or at least to actual version of core-js#2.
warning node-mailer#0.1.1: node-mailer is not maintained
warning jest > jest-cli > prompts > kleur#2.0.2: Please upgrade to kleur#3 or migrate to 'ansi-colors' if you prefer the old syntax. Visit <https://github.com/lukeed/kleur/releases/tag/v3.0.0\> for migration path(s).
warning jest > jest-cli > jest-environment-jsdom > jsdom > left-pad#1.3.0: use String.prototype.padStart()
warning nest-cli > exists-sync#0.0.3: Please replace with usage of fs.existsSync
warning supertest > superagent#3.8.3: Please note that v5.0.1+ of superagent removes User-Agent header by default, therefore you may need to add it yourself (e.g. GitHub blocks requests without a User-Agent header). This notice will go away with v5.0.2+ once it is released.
[2/4] Fetching packages...
info There appears to be trouble with your network connection. Retrying...

You can try to increase --network timeout parameter, adapting it in yarn command line within the shared Dockerfile as #Marc ABOUCHACRA mentioned in the comment:
yarn install --network-timeout 1000000
The issue seems to be very common and not related to minikube VM, just search for the details in this Stack thread.

Related

Install wget in Docker in Codebuild

I'm using the serverless framework to build an application that is using a docker image. In the Dockerfile I have this command
RUN yum install wget -y
RUN wget https://julialang-s3.julialang.org/bin/linux/x64/1.8/julia-1.8.2-linux-x86_64.tar.gz
which works fine locally (windows) and on an Linux EC2 however when I run this through my build on codebuild (Image: aws/codebuild/amazonlinux2-x86_64-standard:4.0 with runtime-versions: docker 20) I get an error
Step 12/19 : RUN yum install wget -y
---> Running in f68d5e0607c3
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.amzn2.1 will be installed
--> Processing Dependency: libidn.so.11(LIBIDN_1.0)(64bit) for package: wget-1.14-18.amzn2.1.x86_64
--> Processing Dependency: libidn.so.11()(64bit) for package: wget-1.14-18.amzn2.1.x86_64
--> Running transaction check
---> Package libidn.x86_64 0:1.28-4.amzn2.0.2 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
wget x86_64 1.14-18.amzn2.1 amzn2-core 547 k
Installing for dependencies:
libidn x86_64 1.28-4.amzn2.0.2 amzn2-core 209 k
Transaction Summary
================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 757 k
Installed size: 2.6 M
Downloading packages:
--------------------------------------------------------------------------------
Total 7.1 MB/s | 757 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libidn-1.28-4.amzn2.0.2.x86_64 1/2
Installing : wget-1.14-18.amzn2.1.x86_64 2/2
Rpmdb checksum is invalid: dCDPT(pkg checksums): libidn.x86_64 0:1.28-4.amzn2.0.2 - u
The command '/bin/sh -c yum install wget -y' returned a non-zero code: 1

How to properly run Docker containers and YARN server with WSL 2 in Windows 10?

The question may be poorly formed, but let me explain.
Initial setup
I had my web-dev Laravel project in C:\dev\gitlab.our-company.com\laravel-backend with a Vue app in .\public\vue-frontend.
I use Docker (using WSL 2 based engine) with the following commands:
// First time
export AUTH_TOKEN='glpat-XXX'
export COMPOSER_AUTH='{"http-basic":{"gitlab.our-company.com": {"username": "oauth2", "password": "${AUTH_TOKEN}"}}}'
docker build -f deployment/app.Dockerfile --build-arg COMPOSER_AUTH -t laravel_backend_app .
docker build -f deployment/web.Dockerfile --build-arg AUTH_TOKEN -t laravel_backend_web .
// Always
docker-compose -f deployment/docker-compose.yml -f deployment/docker-compose.override.yml -p laravel_backend up
Then I open container's bash with
docker-compose -f deployment/docker-compose.yml -f deployment/docker-compose.override.yml -p laravel_backend exec app bash
which in turn allows me to run php artisan test.
I can also run
yarn --cwd ./public/vue-frontend/ install && yarn --cwd ./public/vue-frontend/ serve
to serve the frontend.
Why I made changes
Running php artisan test or vendor/bin/grumphp run in container's bash was ridiculously slow (x10).
Current setup
$ wsl docker --version
Docker version 20.10.12, build e91ed57
Using Ubuntu for Windows with explorer.exe . I copied entire C:\dev to (Ubuntu)~/dev
I rebuilt Docker containers and up-ed them, executed app bash and tried php artisan test. It is now lightning fast.
Question 1
I can do the procedure in the last paragraph in 2 ways.
I can open VS Code integrated terminal in //wsl$/Ubuntu/home/{USER}/dev/gitlab.our-company.com/laravel-backend and do the above procedure directly there, or
as an extra step, when in terminal, I can execute wsl command and my location becomes ~/dev/gitlab.our-company.com/laravel-backend before continuing with said procedure.
In both cases, I get my php artisan test improvement speed.
Which is correct, or for some reason better?
Problem
I had issues with yarn, so in Ubuntu for Windows I installed nvm and then with it nodejs, npm, yarn.
Yarn is installed in both cases, thought a tad different version.
//wsl$/Ubuntu/home/{USER}/dev/gitlab.our-company.com/laravel-backend (205-issue-title)
$ yarn --version
1.22.17
$ wsl
{USER}#DESKTOP-NAME:~/dev/gitlab.our-company.com/laravel-backend$ yarn --version
1.22.15
Now the problem is serving the app.
//wsl$/Ubuntu/home/{USER}/dev/gitlab.our-company.com/laravel-backend (205-issue-title)
$ yarn --cwd ./public/vue-frontend/ install && yarn --cwd ./public/vue-frontend/ serve
yarn install v1.22.17
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[-/3] ⡀ waiting...
[2/3] ⡀ ejs
error \\wsl$\Ubuntu\home\{USER}\dev\gitlab.our-company.com/laravel-backend\public\vue-frontend\node_modules\yorkie: Command failed.
Exit code: 1
Command: node bin/install.js
Arguments:
Directory: \\wsl$\Ubuntu\home\{USER}\dev\gitlab.our-company.com/laravel-backend\public\vue-frontend\node_modules\yorkie
Output:
'\\wsl$\Ubuntu\home\{USER}\dev\gitlab.our-company.com/laravel-backend\public\vue-frontend\node_modules\yorkie'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'C:\Windows\bin\install.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
or with wsl:
{USER}#DESKTOP-3OMP0G1:~/dev/gitlab.our-company.com/laravel-backend$ yarn --cwd ./public/vue-frontend/ install && yarn --cwd ./public/vue-frontend/ serve
yarn install v1.22.15
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "https://gitlab.our-company.com/api/v4/projects/{PROJECT_ID}/packages/npm/#our-company/case-messaging/-/#our-company/case-messaging-1.0.3.tgz: Request failed \"404 Not Found\"".
info If you think this is a bug, please open a bug report with the information provided in "/home/{USER}/dev/gitlab.our-company.com/laravel-backend/public/vue-frontend/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
I now believe the second way ie. in wsl is the right way.
If anyone has a deeper, better or different explanation I will review it, and likely mark it as the accepted answer.
The problem I had with running yarn install in wsl is somewhat unrelated to the question and was caused by an NPM package that resides in Our Company's self hosted GitLab (as opposed to NPM public registry) and npm had no access to download the case-messaging package.
Solved it with
npm config set #our-company:registry https://gitlab.our-company.com/api/v4/projects/{PROJECT_ID}/packages/npm/
npm config set -- '//gitlab.our-company.com/api/v4/projects/{PROJECT_ID}/packages/npm/:_authToken' "${AUTH_TOKEN}"

alpine:3.14 docker libtls.so.20 conflict

So I am running into an error with the latest docker build from alpine. alpine:3.14.0 was released about a day ago and was trying to install libressl and libressl-dev and both seem to fail with the error below. My work around at the moment was to build using the alpine:3.12.0 as 3.12.0 seems to not have libretls installed. Although I would like to know how to fix this. I tried to remove libretls but that didn't work (error also below). Thanks
$ docker -v
Docker version 20.10.6, build 370c289
$ docker run --rm -it alpine /bin/ash
/ # apk add libressl-dev
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
(1/5) Installing libressl3.3-libcrypto (3.3.3-r0)
(2/5) Installing libressl3.3-libssl (3.3.3-r0)
(3/5) Installing libressl3.3-libtls (3.3.3-r0)
ERROR: libressl3.3-libtls-3.3.3-r0: trying to overwrite usr/lib/libtls.so.20 owned by libretls-3.3.3-r0.
ERROR: libressl3.3-libtls-3.3.3-r0: trying to overwrite usr/lib/libtls.so.20.0.3 owned by libretls-3.3.3-r0.
(4/5) Installing pkgconf (1.7.4-r0)
(5/5) Installing libressl-dev (3.3.3-r0)
Executing busybox-1.33.1-r2.trigger
1 error; 41 MiB in 19 packages
/ #
/ # apk info libretls
libretls-3.3.3-r0 description:
port of libtls from libressl to openssl
libretls-3.3.3-r0 webpage:
https://git.causal.agency/libretls/
libretls-3.3.3-r0 installed size:
84 KiB
/ #
/ # apk del libretls
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.14/main: No such file or directory
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.14/community: No such file or directory
World updated, but the following packages are not removed due to:
libretls: busybox alpine-baselayout apk-tools
OK: 6 MiB in 14 packages
/ # exit
this is the upstream issue. Downgrading to alpine 3.13 works for now until the issue is fixed.
Normally docker images support fixed alpine versions (thanks to MrGlass comment). For example
python:3-alpine -> python:3-alpine3.13
php:7.4-fpm-alpine -> php:7.4-fpm-alpine3.13

How to install SSHFS inside Alpine container?

I use php:7.3.2-cli-alpine3.9 as my base image. I also need SSHFS installed inside container since PHP library I use relies on it. I know there are many answers with "if you install SSHFS inside container you are doing it wrong" but in my case I need this software installed inside container not on host.
In my Dockerfile I have
RUN apk update && apk add sshfs;
This command is executed without errors:
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
v3.9.3-21-g265a28802e [http://dl-cdn.alpinelinux.org/alpine/v3.9/main]
v3.9.3-15-g583c0d55e9 [http://dl-cdn.alpinelinux.org/alpine/v3.9/community]
OK: 9764 distinct packages available
(1/12) Installing openssh-keygen (7.9_p1-r4)
(2/12) Installing openssh-client (7.9_p1-r4)
(3/12) Installing fuse-common (3.2.6-r1)
(4/12) Installing fuse3 (3.2.6-r1)
(5/12) Installing libffi (3.2.1-r6)
(6/12) Installing libintl (0.19.8.1-r4)
(7/12) Installing libuuid (2.33-r0)
(8/12) Installing libblkid (2.33-r0)
(9/12) Installing libmount (2.33-r0)
(10/12) Installing pcre (8.42-r1)
(11/12) Installing glib (2.58.1-r2)
(12/12) Installing sshfs (3.5.1-r0)
Executing busybox-1.29.3-r10.trigger
Executing glib-2.58.1-r2.trigger
OK: 25 MiB in 44 packages
But when I am trying to mount remote host
'/usr/bin/sshfs' -C -o reconnect -o 'Port=22' -o 'UserKnownHostsFile=/ssh/known_hosts' -o StrictHostKeyChecking=yes -o 'IdentityFile=/ssh/<FILE>' -o PasswordAuthentication=no '<USER>#<HOST>:/' '/fuse/'
I am getting:
fuse: device not found, try 'modprobe fuse' first
When I am running it I am getting:
modprobe: can't change directory to '/lib/modules': No such file or directory
Am I missing any packages? What else needs to be installed?
Thanks.
In order to run SSHFS inside container it requires privileged permissions.
Install SSHFS by adding this line in Dockerfile:
RUN apk update && apk add sshfs;
Run container:
docker run --privileged=true -it --rm --name alpine-app transfers-image

How to solve `Building CXX object src/CMakeFiles/qpidcommon.dir/qpid/sys/posix/Condition.cpp.o` while compiling qpid-cpp within Docker Alpine?

Qpid-cpp has been compiled in a Ubuntu docker image and the current size is 1.86GB:
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu-qpid-cpp latest 7e60a5eabee1 44 hours ago 1.86 GB
Aim
To compile qpid-cpp within docker alpine to reduce the disk size of the image
Problem
Some packages that are available in Ubuntu are omitted or different in Alpine, e.g.:
ubuntu
RUN apt-get update -y && \
apt-get install -y wget && \
apt-get install -y build-essential python ruby && \
apt-get install -y cmake libblkid-dev e2fslibs-dev libboost-all-dev libaudit-dev
Attempt
In order to find the substitution packages the Dockerfile was built and when an error occurred the required package that is available in Alpine was added.
alpine
RUN apk update && \
apk add wget python ruby cmake build-base boost-dev util-linux-dev
Although most errors were solved, the following issue occurs while compile qpid-cpp within alpine:
[ 17%] Building CXX object
src/CMakeFiles/qpidcommon.dir/qpid/sys/posix/Condition.cpp.o
In file included from
/qpid-cpp/bld/qpid-cpp-1.36.0/src/qpid/sys/posix/Condition.h:31:0,
from /qpid-cpp/bld/qpid-cpp-1.36.0/src/qpid/sys/posix/Condition.cpp:22:
/usr/include/sys/errno.h:1:2: error: #warning redirecting incorrect
#include <sys/errno.h> to <errno.h> [-Werror=cpp]
#warning redirecting incorrect #include <sys/errno.h> to <errno.h>
^~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [src/CMakeFiles/qpidcommon.dir/build.make:2727:
src/CMakeFiles/qpidcommon.dir/qpid/sys/posix/Condition.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1494: src/CMakeFiles/qpidcommon.dir/all]
Error 2 make: *** [Makefile:161: all] Error 2
The command '/bin/sh -c cd qpid-cpp/bld/qpid-cpp-1.36.0 && make all && make
install' returned a non-zero code: 2
Question
How to solve the compilation issue Building CXX object src/CMakeFiles/qpidcommon.dir/qpid/sys/posix/Condition.cpp.o while compiling qpid-cpp within Docker Alpine?
I tried this with Ubuntu and Alpine docker images, and I get the same problem on Alpine. It appears that qpid won't build on Alpine Linux.
Be aware that the Ubuntu:16.04 image is 130 MB, 750 MB with dependencies installed. Compared to Alpine's 5 MB, and 476 MB with dependencies.
So those 1.86 GB are mostly made up of build dependencies and qpid itself. You won't be able to escape that with any other image. Maybe you could purge some of the build dependencies after building to decrease the final size.

Resources