internet connection issue while creating Docker Image - node.js

I am trying to create a simple docker image in AWS EC2.
I have the following Dockerfile.
FROM node:12-alpine
RUN apk add --no-cache build-base gcc autoconf automake libtool zlib-dev libpng-dev nasm
RUN mkdir -p /home/project/website/node_modules && chown -R node:node /home/project/website
WORKDIR /home/project/website
COPY /package*.json ./
USER node
RUN npm cache verify
RUN npm install
COPY --chown=node:node . .
RUN chmod +x wait-for.sh
RUN chmod -R 0755 /home/project/website/src/views/
EXPOSE 8000
when I try to build by this following command
docker-compose build
I got the following output
Step 2/12 : RUN apk add --no-cache build-base gcc autoconf automake libtool zlib-dev libpng-dev nasm
---> Running in 208f43729d68
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz: network error (check Internet connection and firewall)
autoconf (missing):
required by: world[autoconf]
automake (missing):
required by: world[automake]
build-base (missing):
required by: world[build-base]
gcc (missing):
required by: world[gcc]
libpng-dev (missing):
required by: world[libpng-dev]
libtool (missing):
required by: world[libtool]
nasm (missing):
required by: world[nasm]
zlib-dev (missing):
required by: world[zlib-dev]
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz: network error (check Internet connection and firewall)
ERROR: unsatisfiable constraints:
and I have already created it for the first time and everything was running successful, but I have changed some paths on my docker file and I have removed all containers, images, volumes...
but this time I got this error.

I solved the problem by the following commands
pkill docker
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
docker -d
Here is the original answer
My docker container has no internet

Related

Rootless docker causes "failed to resolve address for github.com"

In my dockerfile i'm installing cryptography python dependency however when building wheel from rootless docker i'm getting following error:
...
generating cffi module 'build/temp.linux-x86_64-3.7/_openssl.c'
running build_rust
Updating crates.io index
warning: spurious network error (2 tries remaining): failed to resolve address for github.com: Name does not resolve; class=Net (12)
warning: spurious network error (1 tries remaining): failed to resolve address for github.com: Name does not resolve; class=Net (12)
error: failed to get `pyo3` as a dependency of package `cryptography-rust v0.1.0 (/tmp/pip-install-h22hlaqn/cryptography_a2037904c10949639ccf8a3b2519f187/src/rust)`
Caused by:
failed to fetch `https://github.com/rust-lang/crates.io-index`
Caused by:
network failure seems to have happened
if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
Caused by:
failed to resolve address for github.com: Name does not resolve; class=Net (12)
=============================DEBUG ASSISTANCE=============================
If you are seeing a compilation error please try the following steps to
successfully install cryptography:
1) Upgrade to the latest pip and try again. This will fix errors for most
users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
2) Read https://cryptography.io/en/latest/installation.html for specific
instructions for your platform.
3) Check our frequently asked questions for more information:
https://cryptography.io/en/latest/faq.html
4) Ensure you have a recent Rust toolchain installed:
https://cryptography.io/en/latest/installation.html#rust
5) If you are experiencing issues with Rust for *this release only* you may
set the environment variable `CRYPTOGRAPHY_DONT_BUILD_RUST=1`.
=============================DEBUG ASSISTANCE=============================
...
The strangest thing that the same dockerfile compiles absolutely successfully when built from root user.
I'm using the most recent docker version on arch linux and have tried following instructions here: https://docs.docker.com/engine/security/rootless/ and installing AUR and in both cases had no luck.
That's my docker file:
FROM python:3.7-alpine
ENV LANG C.UTF-8
RUN apk update \
&& apk add --virtual build-deps gcc g++ musl-dev python3 python3-dev autoconf automake linux-headers make libffi-dev openssl-dev \
&& apk add --no-cache bash postgresql-dev libxml2-dev libxslt-dev jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev git openssh-client rust cargo
RUN mkdir -p /opt/carryall/app
RUN mkdir -p /opt/carryall/static
RUN mkdir -p /opt/carryall/media
WORKDIR /opt/carryall/app
RUN mkdir /root/.ssh/
ADD id_rsa /root/.ssh/id_rsa_temp
RUN cat /root/.ssh/id_rsa_temp | tr -d '\r' > /root/.ssh/id_rsa
RUN chmod 400 /root/.ssh/id_rsa
RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts
ADD requirements.txt /opt/carryall/app/
RUN pip install --no-cache-dir -r /opt/carryall/app/requirements.txt
RUN apk del --purge build-deps \
&& rm -rf /root/.cache /tmp/*
ADD . /opt/carryall/app

Docker python3.8 alpine python-ldab installation fails missing lber.h

I am trying to pip install python-ldap in Docker but am missing lber.h. I need python-ldap because I am trying to implement an OS agnostic SSO for my application, following this for now and hoping it doesn't break the rest of my app https://code.tutsplus.com/tutorials/flask-authentication-with-ldap--cms-23101
I have tried
RUN apk add libsasl2-dev libldap2-dev libssl-dev
and
RUN apk --no-cache add libsasl2-dev libldap2-dev libssl-dev
but I get the following error:
ERROR: unsatisfiable constraints:
libldap2-dev (missing):
required by: world[libldap2-dev]
libsasl2-dev (missing):
required by: world[libsasl2-dev]
libssl-dev (missing):
required by: world[libssl-dev]
Having gone to https://pkgs.alpinelinux.org/packages?name=libldap2-dev&branch=edge I feel that it is possible that these packages do indeed not exist within the alpine python image. Therefore, I tried substituting the installations with packages that exist in the above link, namely: openssl libsasl libldap
This didn't work either and had the same effect as not installing any of the packages i.e. the header missing error appeared:
Modules/constants.h:7:10: fatal error: lber.h: No such file or directory
#include "lber.h"
^~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
as a result of /tmp/pip-install-doifa8k9/python-ldap/
My Dockerfile:
FROM python:3.8.0-alpine
WORKDIR /home/flask
ADD . /home/flask
RUN apk --no-cache add --update --virtual .build-editdistance gcc g++ && \
apk --no-cache add libsasl libldap openssl && \
apk --no-cache add --update --virtual .libs libstdc++ && \
apk add linux-headers && \
apk add unixodbc-dev;
RUN rm -rf /var/cache/apk/* && \
pip install --upgrade pip && \
pip install --upgrade setuptools && \
pip install --no-cache-dir -Ur requirements.txt && \
apk del .build-editdistance;
EXPOSE 5000
For alpine python in docker:
apk add openldap-dev
instead of
apk add libsasl libldap openssl
This is answered in I can't install python-ldap but the answer is buried sufficiently deep and obfuscated by the accepted answer ( which is where libsasl libldap openssl came from) that it would be a good idea to keep this docker specific question

Errors when running a JavaFX Spark Application from a Docker Image

I am trying to run an Docker Image of a JavaFX SparkML Application. I can create an image but when it comes to running the image I get an error related to JavaFX.
This is my 1st Docker image and I would appreciate any help to point me in the right direction. I have searched online and tried a few ways to add JavaFX to my docker image but I keep getting the same error!
My Dockerfile:
# build
#FROM maven AS build
FROM maven:3.5.3-jdk-8 AS build
WORKDIR /usr/src/app
COPY pom.xml .
RUN apt-get update
RUN apt-get install -y --no-install-recommends openjfx && rm -rf /var/lib/apt/lists/*
# Install apt-utils
RUN apt-get update
RUN apt-get install -y apt-utils
RUN apt-get install -y curl
# Install openjfx
#RUN apt-get update
#RUN apt-get install -y openjfx
RUN mvn -f /usr/src/app/pom.xml clean package
#RUN mvn -B -e -C -T 1C org.apache.maven.plugins:maven-dependency-plugin:3.1.1:go-offline
COPY . .
#RUN mvn -B -e -o -T 1C verify
# package without maven
FROM openjdk
COPY --from=build /usr/src/app/target/*.jar ./bda-1.0.0-SNAPSHOT.jar
RUN chmod 777 *.jar
EXPOSE 8080
CMD ["java","-jar","./bda-1.0.0-SNAPSHOT.jar"]
And the resulting error:
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
at com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:280)
at com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:222)
at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:260)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:678)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:830)
Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:94)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
... 1 more
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.lang.RuntimeException: No toolkit found
at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:272)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:678)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:830)
JDK still includes JavaFX. Your stacktrace includes JavaFX classes. So I guess this is not your actual problem.
The docker image does not support a UI directly. It's just a container that is rather isolated from your local desktop.
But it seems to be possible to configure the docker container to use your local X-Server for rendering UI. I found this example: https://medium.com/#SaravSun/running-gui-applications-inside-docker-containers-83d65c0db110
Basically, you have to install required X-Server libs into the container and configure display, network and volumes in order to make it work.

How to check if libpcap installed in Alphine docker container

I installed libpcap in my container using below docker file using docker file below. How do I make sure it was installed and working as expected?
I tried below with the hope to see libpcap
D:\work >docker exec -u 0 -it containerId sh
/app # cd /etc/apk
/etc/apk # cat repositories
http://dl-cdn.alpinelinux.org/alpine/v3.8/main
http://dl-cdn.alpinelinux.org/alpine/v3.8/community
/etc/apk #
Below is my docker file
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine AS build
# Install packages
RUN apk update
RUN apk -U --no-cache add libpcap
Running the apk info command has below output
WARNING: Ignoring APKINDEX.adfa7ceb.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.efaa1f73.tar.gz: No such file or directory
musl
busybox
alpine-baselayout
alpine-keys
libressl2.7-libcrypto
libressl2.7-libssl
libressl2.7-libtls
ssl_client
zlib
apk-tools
scanelf
musl-utils
libc-utils
ca-certificates
krb5-conf
libcom_err
keyutils-libs
libverto
krb5-libs
libgcc
libintl
libcrypto1.0
libssl1.0
libstdc++
userspace-rcu
lttng-ust
tzdata
Run docker exec command and try this
$ apk info
This will list all the installed packages in alpine.
I can see libcap in the output.
If you still can't see the package. Make sure you have run apk update before installing libcap

Docker Alpine linux package masked

I am trying to install a package on my docker image that runs alpine but I get the following error,
Removing intermediate container 54bbe0932899
Step 14 : RUN apk add openblas openblas-dev --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
---> Running in 24d7a8c00c89
fetch http://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
openblas-0.2.19-r0:
masked in: #community
satisfies: world[openblas]
openblas-dev-0.2.19-r0[openblas=0.2.19-r0]
openblas-ilp64-0.2.19-r0:
masked in: #community
satisfies:
openblas-dev-0.2.19-r0[openblas-ilp64=0.2.19-r0]
openblas-dev-0.2.19-r0:
masked in: #community
satisfies: world[openblas-dev]
ERROR: Service 'web' failed to build: The command '/bin/sh -c apk add openblas openblas-dev --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted' returned a non-zero code: 3
Important part of the Dockerfile:
FROM python:3.5.2-alpine
ADD repositories /etc/apk/repositories
RUN apk upgrade --update
RUN apk add --update libstdc++ curl ca-certificates bash
RUN apk add openblas openblas-dev --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
RUN apk add --update py-scipy py-numpy py-numpy-dev
The repository file is
http://dl-cdn.alpinelinux.org/alpine/v3.4/main
#testing http://dl-cdn.alpinelinux.org/alpine/edge/testing
#community http://dl-cdn.alpinelinux.org/alpine/edge/community
How I can force the installation of openblas?
I am new to alpine so apologies if this is a straight forward question.
I found the solution,
the following line:
RUN apk add openblas openblas-dev --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
should be
RUN apk add openblas#community openblas-dev#community --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/community/ --allow-untrusted
Now docker continues to the next stage.

Resources