diff --git a/base/Dockerfile b/base/Dockerfile index 05559b1..f26fd76 100644 --- a/base/Dockerfile +++ b/base/Dockerfile @@ -1,5 +1,5 @@ # Base image: Debian-12 -FROM debian:12 +FROM debian:12-slim # Update local package index, upgrade packages and install required packages. RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ @@ -7,6 +7,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins net-tools \ curl \ gnupg \ + netcat-openbsd \ && rm -rf /var/lib/apt/lists/* # Set Java env @@ -39,15 +40,33 @@ RUN mkdir /opt/hadoop-$HADOOP_VERSION/logs /hadoop-data # Set env ENV HADOOP_HOME=/opt/hadoop-$HADOOP_VERSION ENV HADOOP_CONF_DIR=/etc/hadoop +ENV HADOOP_OPTS="--add-opens java.base/java.lang=ALL-UNNAMED" ENV MULTIHOMED_NETWORK=1 -ENV USER=root +ENV USER=hdoop ENV PATH $HADOOP_HOME/bin/:$PATH +# Ensure required config files exist +# RUN mkdir -p /etc/hadoop && \ +# echo "" > /etc/hadoop/core-site.xml && \ +# echo "" > /etc/hadoop/hdfs-site.xml && \ +# echo "" > /etc/hadoop/yarn-site.xml && \ +# echo "" > /etc/hadoop/mapred-site.xml && \ +# echo "" > /etc/hadoop/httpfs-site.xml && \ +# echo "" > /etc/hadoop/kms-site.xml + +# Create non-root user +RUN useradd -m -s /bin/bash hdoop + # Copy entrypoint.sh to container ADD entrypoint.sh /entrypoint.sh +# Set ownership for Hadoop dirs +RUN chown -R hdoop:hdoop /opt/hadoop-$HADOOP_VERSION /etc/hadoop /hadoop-data + # Make entrypoint.sh executable RUN chmod a+x /entrypoint.sh +USER hdoop + # Specify entrypoint ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index ed40dc6..0637e21 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,24 +1,36 @@ -version: "3" - services: namenode: - image: bde2020/hadoop-namenode:2.0.0-hadoop3.2.1-java8 - container_name: namenode - restart: always + image: cc/namenode:1.0 + container_name: cc-namenode + restart: no ports: - - 9870:9870 - - 9000:9000 + - "9870:9870" + - "9000:9000" + user: "1000:1000" + security_opt: + no-new-privileges:true + deploy: + resouces: + cpu: "2" + memory: 4G volumes: - hadoop_namenode:/hadoop/dfs/name environment: - - CLUSTER_NAME=test + - CLUSTER_NAME=ccmini env_file: - ./hadoop.env datanode: - image: bde2020/hadoop-datanode:2.0.0-hadoop3.2.1-java8 - container_name: datanode - restart: always + image: cc/datanode:1.0 + container_name: cc-datanode + restart: no + user: "1000:1000" + security_opt: + no-new-privileges:true + deploy: + resouces: + cpu: "2" + memory: 4G volumes: - hadoop_datanode:/hadoop/dfs/data environment: @@ -27,27 +39,48 @@ services: - ./hadoop.env resourcemanager: - image: bde2020/hadoop-resourcemanager:2.0.0-hadoop3.2.1-java8 - container_name: resourcemanager - restart: always + image: cc/resoucemanager:1.0 + container_name: cc-resourcemanager + restart: no + user: "1000:1000" + security_opt: + no-new-privileges:true + deploy: + resouces: + cpu: "2" + memory: 4G environment: SERVICE_PRECONDITION: "namenode:9000 namenode:9870 datanode:9864" env_file: - ./hadoop.env - nodemanager1: - image: bde2020/hadoop-nodemanager:2.0.0-hadoop3.2.1-java8 - container_name: nodemanager - restart: always + nodemanager: + image: cc/nodemanager:1.0 + container_name: cc-nodemanager + restart: no + user: "1000:1000" + security_opt: + no-new-privileges:true + deploy: + resouces: + cpu: "2" + memory: 4G environment: SERVICE_PRECONDITION: "namenode:9000 namenode:9870 datanode:9864 resourcemanager:8088" env_file: - ./hadoop.env historyserver: - image: bde2020/hadoop-historyserver:2.0.0-hadoop3.2.1-java8 - container_name: historyserver - restart: always + image: cc/historyserver:1.0 + container_name: cc-historyserver + restart: no + user: "1000:1000" + security_opt: + no-new-privileges:true + deploy: + resources: + cpu: "2" + memory: 4G environment: SERVICE_PRECONDITION: "namenode:9000 namenode:9870 datanode:9864 resourcemanager:8088" volumes: