How to mix to Dockerfiles into one

Viewed 110

After some help I succeded to build the image of my Java Application and then able to run it in a container. Now I would like to add ExpressVPN inside the same container and wounder how do I do that? I can see that on DockerHub their is some polkaned/expressvpn with connection to Github to see all the files

Is it possible to just copy the code from the Dockerfile (of polkaned) and add it to my Dockerfile? Then I have understood that I will have to use somekind of script file in my Entrypoint instead where I state the commands and information that needs to get ExpressVPN running.

I have tried but failed. This is how I did:

FROM debian:bullseye-slim

ENV ACTIVATION_CODE Code
ENV LOCATION smart
ENV PREFERRED_PROTOCOL auto
ENV LIGHTWAY_CIPHER auto

ARG APP=expressvpn_3.18.1.0-1_amd64.deb

RUN apt-get update && apt-get install -y --no-install-recommends \
    libterm-readkey-perl ca-certificates wget expect iproute2 curl procps libnm0 \
    && rm -rf /var/lib/apt/lists/* \
    && wget -q "https://www.expressvpn.works/clients/linux/${APP}" -O /tmp/${APP} \
    && dpkg -i /tmp/${APP} \
    && rm -rf /tmp/*.deb \
    && apt-get purge -y --auto-remove wget

COPY entrypoint.sh /tmp/entrypoint.sh
COPY expressvpnActivate.sh /tmp/expressvpnActivate.sh

#
# Build stage
#
FROM maven:3.8.4-openjdk-17 AS build
COPY src /test/src
COPY pom.xml /test
#RUN mvn -f /test/pom.xml clean package
RUN mvn -f /test/pom.xml clean package

#
# Package stage
#

FROM openjdk:17-alpine
COPY --from=build /test/target/test-0.0.1-SNAPSHOT.jar /usr/local/lib/test.jar
ENTRYPOINT ["/bin/bash", "/tmp/entrypoint.sh"]

An image is created but when I try to start it I get the following error:

Error invoking remote method 'docker-run-container': Error: (HTTP code 400) unexpected - OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/bin": permission denied: unknown

I change entrypoint to /bash and got this: Error invoking remote method 'docker-run-container': Error: (HTTP code 400) unexpected - OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "bash": executable file not found in $PATH: unknown

then I removed /bin/bash and got this: Error invoking remote method 'docker-start-container': Error: (HTTP code 400) unexpected - OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/tmp/entrypoint.sh": stat /tmp/entrypoint.sh: no such file or directory: unknown

What I really want to complete is that I in the end would like to be able to run "docker run .." and then ExpressVPN should start and my Java Application should start after ExpressVPN have connected in the same container. Is this possible?

0 Answers
Related