docker curl return unexpected end of file - dockerfile

I'm working to deploy my maven project at IBMCloud from Centos Machine, build completed successfully but while executing the run command "ibmcloud dev run --trace" I'm getting this error
/bin/sh: 1: curl: not found
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
The command '/bin/sh -c mkdir -p /usr/share/maven /usr/share/maven/ref && curl -fsSL http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar -xzC /usr/share/maven --strip-components=1 && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn' returned a non-zero code: 2
FAILED
An error exit status 2 was encountered while building the Docker image.
Dockerfile content
FROM ibmjava:8-sfj
LABEL maintainer="IBM Java Engineering at IBM Cloud"
COPY com.project.presentation/target/com.project.war /app.war
ARG MAVEN_VERSION=3.5.4
ARG USER_HOME_DIR="/root"
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
&& curl -fsSL http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz \
| tar -xzC /usr/share/maven --strip-components=1 \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
COPY mvn-entrypoint.sh /usr/local/bin/mvn-entrypoint.sh
COPY settings-docker.xml /usr/share/maven/ref/
VOLUME "$USER_HOME_DIR/.m2"
ENV JAVA_OPTS=""
ENTRYPOINT [ "sh", "-c", "mvn -pl com.project.presentation -am spring-boot:run" ]
I updated the dockerfile based on the suggestions on this link to have settings-docker.xml and mvn-entrypoint.sh copied Docker image with Maven fails to run

The image does not have curl installed on it. you can check that by simply writing simple Dockerfile as below
FROM ibmjava:8-sfj
RUN curl google.com
Now, this will fail giving below error
...
Status: Downloaded newer image for ibmjava:8-sfj
---> e00902e30a47
Step 2/2 : RUN curl google.com
---> Running in 6b08c670fad2
/bin/sh: 1: curl: not found
The command '/bin/sh -c curl google.com' returned a non-zero code: 127
Install curl on your image by adding following line
RUN apk add --update \
curl \
&& rm -rf /var/cache/apk/*

Related

wget: unable to resolve host address 'github.com'

I am building my dockerfile using Redhat UBI image, and when I build the image I get the wget: unable to resolve host address'github.com'.
I have tried adding a different URL that does not start with GitHub and that works. Not sure what the problem is.
Below are the errors logs i get when i build the docker file with : wget: unable to resolve host address 'github.com'
Step 11/25 : RUN set -ex; apk update; apk add -f acl dirmngr gpg lsof procps wget netcat gosu tini; rm -rf /var/lib/apt/lists/*; cd /usr/local/bin; wget -nv https://github.com/apangin/jattach/releases/download/v1.5/jattach; chmod 755 jattach; echo >jattach.sha512 "d8eedbb3e192a8596c08efedff99b9acf1075331e1747107c07cdb1718db2abe259ef168109e46bd4cf80d47d43028ff469f95e6ddcbdda4d7ffa73a20e852f9 jattach"; sha512sum -c jattach.sha512; rm jattach.sha512
---> Running in 3ad58c40b25a
+ apk update
fetch https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
v20200917-1125-g7274a98dfc [https://dl-cdn.alpinelinux.org/alpine/edge/main]
v20200917-1124-g01e8cb93ff [https://dl-cdn.alpinelinux.org/alpine/edge/community]
OK: 13174 distinct packages available
+ apk add -f acl dirmngr gpg lsof procps wget netcat gosu tini
(1/12) Installing libacl (2.2.53-r0)
(2/12) Installing acl (2.2.53-r0)
(3/12) Installing lsof (4.93.2-r0)
(4/12) Installing libintl (0.20.2-r0)
(5/12) Installing ncurses-terminfo-base (6.2_p20200918-r1)
(6/12) Installing ncurses-libs (6.2_p20200918-r1)
(7/12) Installing libproc (3.3.16-r0)
(8/12) Installing procps (3.3.16-r0)
(9/12) Installing tini (0.19.0-r0)
(10/12) Installing libunistring (0.9.10-r0)
(11/12) Installing libidn2 (2.3.0-r0)
(12/12) Installing wget (1.20.3-r1)
Executing busybox-1.32.0-r3.trigger
OK: 9 MiB in 26 packages
+ rm -rf '/var/lib/apt/lists/*'
+ cd /usr/local/bin
+ wget -nv https://github.com/apangin/jattach/releases/download/v1.5/jattach
wget: unable to resolve host address 'github.com'
The command '/bin/sh -c set -ex; apk update; apk add -f acl dirmngr gpg lsof procps wget netcat gosu tini; rm -rf /var/lib/apt/lists/*; cd /usr/local/bin; wget -nv https://github.com/apangin/jattach/releases/download/v1.5/jattach; chmod 755 jattach; echo >jattach.sha512 "d8eedbb3e192a8596c08efedff99b9acf1075331e1747107c07cdb1718db2abe259ef168109e46bd4cf80d47d43028ff469f95e6ddcbdda4d7ffa73a20e852f9 jattach"; sha512sum -c jattach.sha512; rm jattach.sha512' returned a non-zero code: 4
Here is my docker file that I have which I build to create the image
FROM alpine: edge as BUILD
LABEL maintainer="Project Ranger team <mbyousaf#deloitte.co.uk>"
LABEL repository="https://github.com/docker-solr/docker-solr"
ARG SOLR_VERSION="8.6.2"
ARG SOLR_SHA512="0a43401ecf7946b2724da2d43896cd505386a8f9b07ddc60256cb586873e7e58610d2c34b1cf797323bf06c7613b109527a15105dc2a11be6f866531a1f2cef6"
ARG SOLR_KEYS="E58A6F4D5B2B48AC66D5E53BD4F181881A42F9E6"
# If specified, this will override SOLR_DOWNLOAD_SERVER and all ASF mirrors. Typically used downstream for custom builds
ARG SOLR_DOWNLOAD_URL
# Override the solr download location with e.g.:
# docker build -t mine --build-arg SOLR_DOWNLOAD_SERVER=http://www-eu.apache.org/dist/lucene/solr .
ARG SOLR_DOWNLOAD_SERVER
RUN set -ex; \
apk add --update; \
apk add -f install acl dirmngr gpg lsof procps wget netcat gosu tini; \
rm -rf /var/lib/apt/lists/*; \
cd /usr/local/bin; wget -nv https://github.com/apangin/jattach/releases/download/v1.5/jattach; chmod 755 jattach; \
echo >jattach.sha512 "d8eedbb3e192a8596c08efedff99b9acf1075331e1747107c07cdb1718db2abe259ef168109e46bd4cf80d47d43028ff469f95e6ddcbdda4d7ffa73a20e852f9 jattach"; \
sha512sum -c jattach.sha512; rm jattach.sha512
I would check whether you can resolve github.com on your host where you're doing this build, and I would cat /etc/resolv.conf to see the resolvers of your host. If github.com resolves on your host (which you can see via nslookup github.com), then I would try to use the resolvers explicitly by either configuring the Docker daemon to use it as seen here and here or I would try to do it at a per command level as suggested in an answer here, which is kind of creative.
RUN echo "nameserver XX.XX.XX.XX" > /etc/resolv.conf && \
command_depending_on_dns_resolution

Sawtooth-supply-chain /bin/sh: 1: bin/splice_json: Permission denied

I am trying to run sawtooth-supply-chain from my own computer to get a better understanding of the environment. However, I've run into an issue after running
docker-compose up
git clone https://github.com/hyperledger/sawtooth-supply-chain
cd sawtooth-supply-chain
git diff 50c404c >bionic.patch
patch --dry-run -R -p1 <bionic.patch
patch -R -p1 <bionic.patch
sudo docker-compose up
I am now running into an error at step 9/11 which is the splice_JSON file build
Step 9/11 : RUN mkdir /node_deps && bin/splice_json asset_client/package.json fish_client/package.json server/package.json > /node_deps/package.json && cd /node_deps && npm install && cd - && ln -s /node_deps/node_modules asset_client/ && ln -s /node_deps/node_modules fish_client/ && ln -s /node_deps/node_modules server/
---> Running in ed3fb485568e
/bin/sh: 1: bin/splice_json: Permission denied
Service 'shell' failed to build: The command '/bin/sh -c mkdir /node_deps && bin/splice_json asset_client/package.json fish_client/package.json server/package.json > /node_deps/package.json && cd /node_deps && npm install && cd - && ln -s /node_deps/node_modules asset_client/ && ln -s /node_deps/node_modules fish_client/ && ln -s /node_deps/node_modules server/' returned a non-zero code: 126
I tried to do chmod 777 /bin/splice_json and run git bash on elevated
Any assistance is appreciated
Running patch may have removed executible permission from one or more files under ./bin. Before running docker-compose, restore execute permission on all ./bin/* files:
chmod +x ./bin/*

AWS Session Manager in docker output ^# indefinitely

I've build a custom docker image from python:3.6 with awscli and session manager:
FROM python:3.6
WORKDIR /app
RUN pip3 install -U awscli
RUN apt-get update -y && \
apt-get install groff less curl -y && \
curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb" -o "session-manager-plugin.deb" && \
dpkg -i session-manager-plugin.deb && \
rm -f session-manager-plugin.deb
RUN curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb" -o "session-manager-plugin.deb" && \
dpkg -i session-manager-plugin.deb && \
rm -f session-manager-plugin.deb
ENTRYPOINT ["aws"]
I've created a custom executable file under /usr/bin/aws:
#!/bin/bash
docker run --rm -v "$(pwd)":"/app" -v "/root/.aws/":"/root/.aws" python-aws "$#"
When I run aws ssm start-session --target i-*** the output is:
^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#
^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#
...
Do you know how to solve the issue?
Just found the solution will writing the question.
I added -it (interactive) to the docker run command.
So the the command is now:
#!/bin/bash
docker run -it --rm -v "$(pwd)":"/app" -v "/root/.aws/":"/root/.aws" python-aws "$#"
Problem solved.

What is correct working IBM repository for Liberty profile docker image

I am trying to build docker image with Liberty profile.Using below location Docker file.
https://github.com/WASdev/ci.docker/blob/master/ga/developer/kernel/Dockerfile
FROM ibmjava:8-jre
RUN apt-get update \
&& apt-get install -y --no-install-recommends unzip \
&& rm -rf /var/lib/apt/lists/*
#Install WebSphere Liberty
ENV LIBERTY_VERSION 16.0.0_03
ARG LIBERTY_URL
ARG DOWNLOAD_OPTIONS=""
RUN LIBERTY_URL=${LIBERTY_URL:-$(wget -q -O - https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/downloads/wlp/index.yml | grep $LIBERTY_VERSION -A 6 | sed -n 's/\s*kernel:\s//p' | tr -d '\r' )} \
&& wget $DOWNLOAD_OPTIONS $LIBERTY_URL -U UA-IBM-WebSphere-Liberty-Docker -O /tmp/wlp.zip \
&& unzip -q /tmp/wlp.zip -d /opt/ibm \
&& rm /tmp/wlp.zip
ENV PATH=/opt/ibm/wlp/bin:$PATH
# Set Path Shortcuts
ENV LOG_DIR=/logs \
WLP_OUTPUT_DIR=/opt/ibm/wlp/output
RUN mkdir /logs \
&& ln -s $WLP_OUTPUT_DIR/defaultServer /output \
&& ln -s /opt/ibm/wlp/usr/servers/defaultServer /config
# Configure WebSphere Liberty
RUN /opt/ibm/wlp/bin/server create \
&& rm -rf $WLP_OUTPUT_DIR/.classCache /output/workarea
COPY docker-server /opt/ibm/docker/
EXPOSE 9080 9443
CMD ["/opt/ibm/docker/docker-server", "run", "defaultServer"]**
When I build docker image using this code we are getting error like below.Looks like this repository is not active now.Can anyone provide valid repository.
CWWKF1219E: The IBM WebSphere Liberty Repository cannot be reached. Verify that your computer has network access and firewalls are configured correctly, then try the action again. If the connection still fails, the repository server might be temporarily unavailable.
The URL is correct.
As the error message indicates, try checking your network config. To do that you can try to reach this link in a web browser. (this URL is simply from the script)
https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/downloads/wlp/index.yml
Also, you could testing your connection to the repository outside of the docker environment by doing:
$WLP_HOME/bin/installUtility testConnection
If you are able to ping the repo from your computer, but not within the docker container, then perhaps your docker container has no internet access.
To fix the "docker can't access internet" issue, it looks like the solution from the above link was to do:
service docker restart

Dockerfile works when every line run interactively, but fails using docker build

I have a simple Dockerfile that downloads the node.js source tarball, checksums it, extracts it, builds and installs it. The checksum works when manually run in an interactive docker container, but fails when running the exact same commands when building a Dockerfile.
Works:
docker run -i -t ubuntu:12.04 /bin/bash
cd /tmp
apt-get update -y
apt-get install wget build-essential automake -y
wget http://nodejs.org/dist/latest/node-v0.10.26.tar.gz
wget http://nodejs.org/dist/latest/SHASUMS256.txt
sha256sum -c SHASUM256.txt 2>&1|grep -qs OK
tar -xvf node-v0.10.26.tar.gz && cd node-v0.10.26
./configure && make && make install
Doesn't work:
sudo docker build -t="my_docker_node_image_01" .
Error is:
sudo docker build -t="my_docker_node_image_01" .
Uploading context 7.168 kB
Uploading context
Step 0 : FROM ubuntu:12.04
---> 9cd978db300e
Step 1 : RUN cd /tmp
---> Using cache
---> 0467ad75bbd6
Step 2 : RUN apt-get update -y
---> Using cache
---> d2933f250090
Step 3 : RUN apt-get install wget build-essential automake -y
---> Using cache
---> e8a71b28782a
Step 4 : RUN wget http://nodejs.org/dist/latest/node-v0.10.26.tar.gz
---> Using cache
---> bae7de7b46f7
Step 5 : RUN wget http://nodejs.org/dist/latest/SHASUMS256.txt
---> Using cache
---> 245f6b6ceb84
---> 77532c879864
Step 6 : RUN sha256sum -c SHASUM256.txt 2>&1|grep -qs OK
---> Running in 77765e80f55b
2014/04/22 22:27:32 The command [/bin/sh -c sha256sum -c SHASUM256.txt 2>&1|grep -qs OK] returned a non-zero code: 1
I tried adding less SHASUMS256.txt to the Dockerfile just to confirm that file is successfully downloaded uncorrupted, and it is, but still getting the error anyway.
I'm not sure how to troubleshoot this since normally I would just manually run all the steps in an interactive container to see what goes wrong. Any suggestions much appreciated.
I think I figured this out and it's just a typo, at least when I cut and paste your commands above! You download SHASUMS256.txt but test against a file called SHASUM256.txt (missing the S). Because you throw away the output and pipe it to grep, you weren't seeing that error.
$ sha256sum -c SHASUM256.txt
sha256sum: SHASUM256.txt: No such file or directory
$ sha256sum -c SHASUM256.txt 2>&1|grep -qs OK
$ echo $?
1
Doing an echo $? tells you the return code of the last command executed (in this case 1). By correcting the file, it works for me now:
$ sha256sum -c SHASUMS256.txt 2>&1|grep -qs OK
$ echo $?
0