Last active
August 18, 2017 19:26
-
-
Save levlas/efb8a38f25fa997029bd0ebb1b7ecf10 to your computer and use it in GitHub Desktop.
nexus docker volume ownership problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# my docker environment is clean, there isn't any images, volumes or containers | |
# then | |
# goto proper directory | |
docker build -t leventel/nexus-conf-store:17.08 . | |
# goto another directory | |
docker build -t leventel/nexus-server:test . | |
# goto directory for docker-compose | |
docker-compose up | |
#output of ls -al /var/lib/docker/volumes/ | |
# ls -al /var/lib/docker/volumes/nexusserver_config-export/ | |
total 12 | |
drwxr-xr-x 3 root root 4096 Aug 18 19:57 . | |
drwx------ 5 root root 4096 Aug 18 19:57 .. | |
drwxr-xr-x 2 root root 4096 Aug 18 19:57 _data | |
# ls -al /var/lib/docker/volumes/nexusserver_nexus-data/ | |
total 12 | |
drwxr-xr-x 3 root root 4096 Aug 18 19:57 . | |
drwx------ 5 root root 4096 Aug 18 19:57 .. | |
drwx------ 18 200 200 4096 Aug 18 19:58 _data | |
### UPDATE it is working as expected also for the volumes_from: | |
# ls -al /var/lib/docker/volumes/4d6a135a6debec189ab2744226de84023239a64cb63c7f20a45c6516c1021835/ | |
total 12 | |
drwxr-xr-x 3 root root 4096 Aug 18 21:23 . | |
drwx------ 5 root root 4096 Aug 18 21:23 .. | |
drwxr-xr-x 2 200 200 4096 Aug 18 21:23 _data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "2" | |
services: | |
config_storage: | |
image: leventel/nexus-conf-store:17.08 | |
container_name: nexus_conf_store | |
nexus: | |
image: leventel/nexus-server:test | |
container_name: nexus_server | |
volumes: | |
- nexus-data:/nexus-data | |
- config-export:/nexus-data/config-export | |
volumes_from: | |
- config_storage:ro | |
ports: | |
- "8081:8081" | |
restart: on-failure | |
depends_on: | |
- config_storage | |
volumes: | |
nexus-data: | |
config-export: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM sonatype/nexus3:3.5.0 | |
ENV OLD_AVON_BLOBS=/app/sonatype-work/avon-maps/blobs \ | |
NEW_AVON_BLOBS=/nexus-data/blobs \ | |
CONFIG_EXPORT=/nexus-data/config-export | |
USER root | |
RUN mkdir -p ${OLD_AVON_BLOBS} \ | |
&& ln -s ${NEW_AVON_BLOBS}/avon-maps ${OLD_AVON_BLOBS}/avon-maps \ | |
&& chown -R nexus:nexus ${OLD_AVON_BLOBS} | |
RUN mkdir -p ${CONFIG_EXPORT} \ | |
&& chown nexus:nexus ${CONFIG_EXPORT} | |
VOLUME ${CONFIG_EXPORT} | |
COPY nexus_init.sh /entrypoint.sh | |
RUN chmod +x /entrypoint.sh | |
USER nexus | |
CMD [""] | |
ENTRYPOINT /entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:3.6 | |
ENV BACKUP_FOLDER=/nexus-data/backup | |
RUN mkdir -p ${BACKUP_FOLDER} \ | |
&& chown 200:200 ${BACKUP_FOLDER} | |
COPY ./foo ${BACKUP_FOLDER} | |
VOLUME ${BACKUP_FOLDER} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2016-present Sonatype, Inc. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
FROM centos:centos7 | |
MAINTAINER Sonatype <cloud-ops@sonatype.com> | |
LABEL vendor=Sonatype \ | |
com.sonatype.license="Apache License, Version 2.0" \ | |
com.sonatype.name="Nexus Repository Manager base image" | |
ARG NEXUS_VERSION=3.5.0-02 | |
ARG NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/nexus-${NEXUS_VERSION}-unix.tar.gz | |
RUN yum install -y \ | |
curl tar \ | |
&& yum clean all | |
# configure java runtime | |
ENV JAVA_HOME=/opt/java \ | |
JAVA_VERSION_MAJOR=8 \ | |
JAVA_VERSION_MINOR=141 \ | |
JAVA_VERSION_BUILD=15 \ | |
JAVA_DOWNLOAD_HASH=336fa29ff2bb4ef291e347e091f7f4a7 | |
# configure nexus runtime | |
ENV SONATYPE_DIR=/opt/sonatype | |
ENV NEXUS_HOME=${SONATYPE_DIR}/nexus \ | |
NEXUS_DATA=/nexus-data \ | |
NEXUS_CONTEXT='' \ | |
SONATYPE_WORK=${SONATYPE_DIR}/sonatype-work | |
# install Oracle JRE | |
RUN mkdir -p /opt \ | |
&& curl --fail --silent --location --retry 3 \ | |
--header "Cookie: oraclelicense=accept-securebackup-cookie; " \ | |
http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/${JAVA_DOWNLOAD_HASH}/server-jre-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.tar.gz \ | |
| gunzip \ | |
| tar -x -C /opt \ | |
&& ln -s /opt/jdk1.${JAVA_VERSION_MAJOR}.0_${JAVA_VERSION_MINOR} ${JAVA_HOME} | |
# install nexus | |
RUN mkdir -p ${NEXUS_HOME} \ | |
&& curl --fail --silent --location --retry 3 \ | |
${NEXUS_DOWNLOAD_URL} \ | |
| gunzip \ | |
| tar x -C ${NEXUS_HOME} --strip-components=1 nexus-${NEXUS_VERSION} \ | |
&& chown -R root:root ${NEXUS_HOME} | |
# configure nexus | |
RUN sed \ | |
-e '/^nexus-context/ s:$:${NEXUS_CONTEXT}:' \ | |
-i ${NEXUS_HOME}/etc/nexus-default.properties \ | |
&& sed \ | |
-e '/^-Xms/d' \ | |
-e '/^-Xmx/d' \ | |
-i ${NEXUS_HOME}/bin/nexus.vmoptions | |
RUN useradd -r -u 200 -m -c "nexus role account" -d ${NEXUS_DATA} -s /bin/false nexus \ | |
&& mkdir -p ${NEXUS_DATA}/etc ${NEXUS_DATA}/log ${NEXUS_DATA}/tmp ${SONATYPE_WORK} \ | |
&& ln -s ${NEXUS_DATA} ${SONATYPE_WORK}/nexus3 \ | |
&& chown -R nexus:nexus ${NEXUS_DATA} | |
VOLUME ${NEXUS_DATA} | |
EXPOSE 8081 | |
USER nexus | |
WORKDIR ${NEXUS_HOME} | |
ENV INSTALL4J_ADD_VM_PARAMS="-Xms1200m -Xmx1200m" | |
CMD ["bin/nexus", "run"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Clean up former configuration of Nexus (run as nexus user) so that it will start with a config restore | |
# from $NEXUS_DATA/backup folder (it is mounted from a separate data container) | |
NEXUS_HOME=/opt/sonatype/nexus | |
NEXUS_DATA=/nexus-data | |
NEXUS_DB=$NEXUS_DATA/db | |
rm -rf \ | |
$NEXUS_DB/accesslog \ | |
$NEXUS_DB/analytics \ | |
$NEXUS_DB/audit \ | |
$NEXUS_DB/component \ | |
$NEXUS_DB/config \ | |
$NEXUS_DB/security | |
$NEXUS_HOME/bin/nexus run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment