Running Startup script in Docker

Viewed 1423

I have build docker image from below:

FROM rocker/r-ubuntu:20.04

LABEL maintainer="Utkarsh Saraf"

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y  software-properties-common \
    apt-utils \
    libxml2-dev \
    openjdk-8-jdk \
    build-essential \
    libcurl4-gnutls-dev \
    libssl-dev \
    openssh-server && \
    apt-get clean


WORKDIR /app
COPY . /app
COPY start.sh /start.sh
RUN chmod +x /start.sh
ENTRYPOINT ["sh","/app/startup.sh"]

In startup.sh, following code contains:

java web-app.jar &

How to execute shell file.

1 Answers

I faced same issue & it resolved by just replace the

RUN chmod +x /start.sh
CMD ["startup.sh"]

by

 ENTRYPOINT ["sh", "/app/startup.sh"]

your final dockerfile will be:

FROM rocker/r-ubuntu:20.04

LABEL maintainer="Utkarsh Saraf"

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y  software-properties-common \
    apt-utils \
    libxml2-dev \
    openjdk-8-jdk \
    build-essential \
    libcurl4-gnutls-dev \
    libssl-dev \
    openssh-server && \
    apt-get clean


# for enabling SSh in container ------------------------------#
EXPOSE 80 2222 3306 8081

WORKDIR /app
COPY . /app
COPY start.sh start.sh
ENTRYPOINT ["sh", "/app/startup.sh"]

I hope that this part can help you to resolve your issue

Related