Docker Community Forums

Share and learn in the Docker community.

Returned a non zero code: 1 | Docker-compose fails

I have a problem and no clue at all what the cause is. I am pretty new to docker and I hope I included all necessary informations. I am using Docker-Toolbox on a Windows 7 64-bit. The Java-Webapp that should be deployed in the Tomcat-server is build with Maven.

#Steps to reproduce:
User@PC MINGW64 ~/Tomcat
$ ls
docker-compose.yml nb-configuration.xml pom.xml Readme.md target/ tomcat/

User@PC MINGW64 ~/Tomcat
$ docker-compose up -d --build

#Result(the part in which bad stuff happens):
Step 16/22 : RUN set -x && apk add --no-cache --virtual .fetch-d
eps ca-certificates tar openssl
&& wget -O tomcat.tar.gz “$TOMCAT_TGZ_URL” && wget -O tomcat.tar.gz.asc “$T
OMCAT_ASC_URL” && gpg --batch --verify tomcat.tar.gz.asc tomcat.tar.gz
&& tar -xvf tomcat.tar.gz --strip-components=1 && rm bin/.bat && rm to
mcat.tar.gz
&& nativeBuildDir="$(mktemp -d)" && tar -xvf bin/
tomcat-native.tar.gz -C “$nativeBuildDir” --strip-components=1 && apk add --no-
cache --virtual .native-build-deps apr-dev gcc
libc-dev make “openjdk${JAVA_VERSION%%[-~bu]}
"="$JAVA_ALPINE_VERSION" openssl-dev && ( export C
ATALINA_HOME="$PWD" && cd “$nativeBuildDir/native” && ./con
figure --libdir="$TOMCAT_NATIVE_LIBDIR"
–prefix="$CATALINA_HOME" --with-apr="$(which apr-1-config
)" --with-java-home="$(docker-java-home)"
–with-ssl=yes && make -j$(getconf _NPROCESSORS_ONLN) && make
install ) && runDeps="$( scanelf --needed --nobanner --re
cursive “$TOMCAT_NATIVE_LIBDIR” | awk ‘{ gsub(/,/, “\nso
:”, $2); print “so:” $2 }’ | sort -u
| xargs -r apk info --installed | sort -u )"
&& apk add --virtual .tomcat-native-rundeps $runDeps && apk del .fetch-deps .
native-build-deps && rm -rf “$nativeBuildDir” && rm bin/tomcat-native.
tar.gz
—> Running in 1682b9370223
←[91m+ apk add --no-cache --virtual .fetch-deps ca-certificates tar openssl
←[0mfetch (A Link I cannot show here because of 2 Link-Limit)
fetch (A Link I cannot show here because of 2 Link-Limit)
(1/3) Installing tar (1.29-r1)
(2/3) Installing openssl (1.0.2k-r0)
(3/3) Installing .fetch-deps (0)
Executing busybox-1.24.2-r12.trigger
Executing ca-certificates-20160104-r4.trigger
OK: 122 MiB in 54 packages
←[91m+ wget -O tomcat.tar.gz (A Link I cannot show here because of 2 Link-Limit)
←[0m←[91mConnecting to (A Link I cannot show here because of 2 Link-Limit) (140.211.11.105:443)
←[0m←[91mConnecting to apache.lauf-forum.at (5.9.138.111:80)
←[0m←[91mwget: server returned error: HTTP/1.1 404 Not Found
←[0m←[31mERROR←[0m: Service ‘web’ failed to build: The command '/bin/sh -c set -
x && apk add --no-cache --virtual .fetch-deps ca-certi
ficates tar openssl && wget -O tomcat.tar.gz
"$TOMCAT_TGZ_URL" && wget -O tomcat.tar.gz.asc “$TOMCAT_ASC_URL” && gpg -
-batch --verify tomcat.tar.gz.asc tomcat.tar.gz && tar -xvf tomcat.tar.g
z --strip-components=1 && rm bin/
.bat && rm tomcat.tar.gz*
&& nativeBuildDir=”$(mktemp -d)" && tar -xvf bin/tomcat-native.tar.gz -C
"$nativeBuildDir" --strip-components=1 && apk add --no-cache --virtual .native-
build-deps apr-dev gcc libc-dev
make “openjdk${JAVA_VERSION%%[-~bu]*}”="$JAVA_ALPINE_VERSION"
openssl-dev && ( export CATALINA_HOME="$PWD"
&& cd “$nativeBuildDir/native” && ./configure
–libdir="$TOMCAT_NATIVE_LIBDIR" --prefix="$CATALINA_HOME
" --with-apr="$(which apr-1-config)"
–with-java-home="$(docker-java-home)" --with-ssl=yes
&& make -j$(getconf NPROCESSORS_ONLN) && make install )
&& runDeps="$( scanelf --needed --nobanner --recursive "$TOMCAT_NATIVE

LIBDIR" | awk ‘{ gsub(/,/, “\nso:”, $2); print “so:” $2
}’ | sort -u | xargs -r apk info --in
stalled | sort -u )" && apk add --virtual .to
mcat-native-rundeps $runDeps && apk del .fetch-deps .native-build-deps
&& rm -rf “$nativeBuildDir” && rm bin/tomcat-native.tar.gz’ returned a non-z
ero code: 1

#docker-compose.yml
version: ‘2’

services:
web:
# Dockerfile in directory ‘tomcat’ will be used
build: ./tomcat
# The name of the container
container_name: emit-tomcat
# Ports that should be opened | 8000:8000 for debug
ports:
- “8080:8080”
- “8000:8000”
# hostname of container
hostname: tomcat
# volumes that should exist in VM and locally
volumes:
- ./target:/usr/local/tomcat/webapps
- ./.srv/tomcatlogs:/usr/local/tomcat/logs
# needs a link to our mysql-db
links:
- db
# neccesary restart
restart: always

db:
# variables are specified in .env
env_file: .env
# lazy image pull
image: mysql:${MYSQL_VERSION}
# container name
container_name: emit-mysql
# specification of mysql
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_USER: ${MYSQL_USER}
MYSQL_ALLOW_EMPTY_PASSWORD: ${MYSQL_ALLOW_EMPTY_PASSWORD}
# volumes that should exist in VM and locally
volumes:
- ./.srv/mysql-${MYSQL_VERSION}:/var/lib/mysql
# neccesary restart
restart: always

phpmyadmin:
# variables are specified in .env
env_file: .env
# lazy image pull
image: phpmyadmin/phpmyadmin
# container name
container_name: emit-phpmyadmin
# needs db to exist
depends_on:
- db
# needs link to db
links:
- db
ports:
# dem ports
- 8181:80
# specification of mysql for login
environment:
PMA_ARBITRARY: 1
PMA_USER: ${MYSQL_USER}
PMA_PASSWORD: ${MYSQL_PASSWORD}
# neccesary restart
restart: always

#Dockerfile
FROM openjdk:8-jre-alpine

(#) Add Bash :slight_smile:
RUN apk add --update bash && rm -rf /var/cache/apk/*

ENV CATALINA_HOME /usr/local/tomcat
ENV PATH $CATALINA_HOME/bin:$PATH
RUN mkdir -p "$CATALINA_HOME"
WORKDIR $CATALINA_HOME

ENV TOMCAT_NATIVE_LIBDIR $CATALINA_HOME/native-jni-lib
ENV LD_LIBRARY_PATH ${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$TOMCAT_NATIVE_LIBDIR

RUN apk add --no-cache gnupg

ENV GPG_KEYS 05AB33110949707C93A279E3D3EFE6B686867BA6 07E48665A34DCAFAE522E5E6266191C37C037D42 47309207D818FFD8DCD3F83F1931D684307A10A5 541FBE7D8F78B25E055DDEE13C370389288584E7 61B832AC2F1C5A90F0F9B00A1C506407564C17A3 713DA88BE50911535FE716F5208B0AB1D63011C7 79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED 9BA44C2621385CB966EBA586F72C284D731FABEE A27677289986DB50844682F8ACB77FC2E86E29AC A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23
RUN set -ex;
for key in $GPG_KEYS; do
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys “$key”;
done

ENV TOMCAT_MAJOR 8
ENV TOMCAT_VERSION 8.0.39

ENV TOMCAT_TGZ_URL (A Link I cannot show here because of 2 Link-Limit)
(#) not all the mirrors actually carry the .asc files :’(
ENV TOMCAT_ASC_URL (A Link I cannot show here because of 2 Link-Limit)

RUN set -x

&& apk add --no-cache --virtual .fetch-deps
ca-certificates
tar
openssl
&& wget -O tomcat.tar.gz “$TOMCAT_TGZ_URL”
&& wget -O tomcat.tar.gz.asc “$TOMCAT_ASC_URL”
&& gpg --batch --verify tomcat.tar.gz.asc tomcat.tar.gz
&& tar -xvf tomcat.tar.gz --strip-components=1
&& rm bin/.bat
&& rm tomcat.tar.gz


&& nativeBuildDir="$(mktemp -d)"
&& tar -xvf bin/tomcat-native.tar.gz -C “$nativeBuildDir” --strip-components=1
&& apk add --no-cache --virtual .native-build-deps
apr-dev
gcc
libc-dev
make
“openjdk${JAVA_VERSION%%[-~bu]*}”="$JAVA_ALPINE_VERSION"
openssl-dev
&& (
export CATALINA_HOME="$PWD"
&& cd “$nativeBuildDir/native”
&& ./configure
–libdir="$TOMCAT_NATIVE_LIBDIR"
–prefix="$CATALINA_HOME"
–with-apr="$(which apr-1-config)"
–with-java-home="$(docker-java-home)"
–with-ssl=yes
&& make -j$(getconf _NPROCESSORS_ONLN)
&& make install
)
&& runDeps="$(
scanelf --needed --nobanner --recursive “$TOMCAT_NATIVE_LIBDIR”
| awk ‘{ gsub(/,/, “\nso:”, $2); print “so:” $2 }’
| sort -u
| xargs -r apk info --installed
| sort -u
)"
&& apk add --virtual .tomcat-native-rundeps $runDeps
&& apk del .fetch-deps .native-build-deps
&& rm -rf “$nativeBuildDir”
&& rm bin/tomcat-native.tar.gz

(#) ADD JDB Connector
ADD mysql-connector-java-5.1.40-bin.jar /usr/local/tomcat/lib/mysql-connector-java-5.1.40-bin.jar

(#) ADD JPDA PORT FOR REMOTE DEBUG
ENV JPDA_ADDRESS="8000"
ENV JPDA_TRANSPORT=“dt_socket”

(#) verify Tomcat Native is working properly
RUN set -e
&& nativeLines="$(catalina.sh configtest 2>&1)"
&& nativeLines="$(echo “$nativeLines” | grep ‘Apache Tomcat Native’)"
&& nativeLines="$(echo “$nativeLines” | sort -u)"
&& if ! echo “$nativeLines” | grep ‘INFO: Loaded APR based Apache Tomcat Native library’ >&2; then
echo >&2 “$nativeLines”;
exit 1;
fi

EXPOSE 8080 8000
CMD [“catalina.sh”, “jpda”, “run”]

#OS:
Microsoft Windows [Version 6.1.7601]

#Docker Info:
$ docker info
Containers: 4
Running: 0
Paused: 0
Stopped: 4
Images: 16
Server Version: 1.13.0
Storage Driver: aufs
Root Dir: /mnt/sda1/var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 28
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.4.43-boot2docker
Operating System: Boot2Docker 1.13.0 (TCL 7.2); HEAD : 5b8d9cb - Wed Jan 18 18:5
0:40 UTC 2017
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 995.8 MiB
Name: default
ID: 7HFS:YGNJ:NNEV:TOZV:SXNT:FKLW:TIGW:YW2G:FUMM:NSKT:JYQD:YYDN
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 14
Goroutines: 23
System Time: 2017-02-02T13:31:31.443073905Z
EventsListeners: 0
Registry: (A Link I cannot show here because of 2 Link-Limit)
Labels:
provider=virtualbox
Insecure Registries:
127.0.0.0/8

#Docker Version:
Client:
Version: 1.12.6
API version: 1.24
Go version: go1.6.4
Git commit: 78d1802
Built: Wed Jan 11 00:23:16 2017
OS/Arch: windows/amd64

Server:
Version: 1.13.0
API version: 1.25
Go version: go1.7.3
Git commit: 49bf474
Built: Wed Jan 18 16:20:26 2017
OS/Arch: linux/amd64

No one has a clue? I still cannot remove this error.

did you provide these volumes?

I am trying to get the logs from the tomcat-server in the .srv directory on my OS. It allready worked this way on 2 different Laptops.
I hope this answeres your question. I was not 100% sure if you meant this.

your docker build fails…and a reason could be, that you do not provide the necessary configuration within these volumes

But I actually don’t configure anything in the volumes. I reference my Dockerfile within the docker-compose.yml

Dockerfile in directory ‘tomcat’ will be used

build: ./tomcat

The only thing that I want to express through the volume-statements is to get files accessible from the server on my OS.

Problem solved:

The mirror of apache did not provide Tomcat 8.0.39 anymore. Seems they took it offline for no reason. Changing the version to 8.0.41 solves all of my problems.