Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Securing docker #89

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ LABEL org.label-schema.name="ONOS" \
RUN apt-get update && apt-get install -y curl && \
rm -rf /var/lib/apt/lists/*

# Install ONOS in /root/onos
COPY --from=builder /output/ /root/onos/
WORKDIR /root/onos
# Add system user with no-login shell
RUN groupadd -g 1000 onos && useradd -r -s /bin/false -u 1000 -g onos onos

ENV APP_DIR /app/onos
WORKDIR ${APP_DIR}
RUN chown -R 1000:1000 ${APP_DIR}

COPY --from=builder /output/ ${APP_DIR}

# Set JAVA_HOME (by default not exported by zulu images)
ARG JAVA_PATH
Expand All @@ -83,6 +88,10 @@ ENV JAVA_HOME ${JAVA_PATH}
# 9876 - ONOS intra-cluster communication
EXPOSE 6653 6640 8181 8101 9876

RUN chown -R 1000:1000 ${APP_DIR}
# Non-root user
USER onos

# Run ONOS
ENTRYPOINT ["./bin/onos-service"]
CMD ["server"]