手动构建最新版本的Nacos镜像 并通过docker-compose 运行

手动 构建最新版本的Nacos镜像 并通过docker-compose 运行

1.下载nacos-docker-master

	[git地址](https://github.com/nacos-group/nacos-docker)
	后边加.git 直接拉取可以跳过墙

2.下载最新版本的Nacos包放在build文件夹下

	[版本汇总地址](https://github.com/alibaba/nacos/releases)

3.进入build目录,修改Dockerfile

FROM centos:7.9.2009
MAINTAINER pader "[email protected]"

# set environment
ENV MODE="standalone" \
    PREFER_HOST_MODE="ip"\
    BASE_DIR="/home/nacos" \
    CLASSPATH=".:/home/nacos/conf:$CLASSPATH" \
    CLUSTER_CONF="/home/nacos/conf/cluster.conf" \
    FUNCTION_MODE="all" \
    JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk" \
    NACOS_USER="nacos" \
    JAVA="/usr/lib/jvm/java-1.8.0-openjdk/bin/java" \
    JVM_XMS="1g" \
    JVM_XMX="1g" \
    JVM_XMN="512m" \
    JVM_MS="128m" \
    JVM_MMS="320m" \
    NACOS_DEBUG="n" \
    TOMCAT_ACCESSLOG_ENABLED="false" \
    TIME_ZONE="Asia/Shanghai"

ARG NACOS_VERSION=2.2.3
ARG HOT_FIX_FLAG=""

WORKDIR $BASE_DIR

RUN set -x \
    && yum update -y \
    && yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel wget iputils nc vim libcurl
COPY ./nacos-server-${NACOS_VERSION}.tar.gz  /home
RUN tar -xzvf /home/nacos-server-${NACOS_VERSION}.tar.gz -C /home \
    && rm -rf /home/nacos-server-${NACOS_VERSION}.tar.gz /home/nacos/bin/* /home/nacos/conf/*.properties /home/nacos/conf/*.example /home/nacos/conf/nacos-mysql.sql
RUN yum autoremove -y wget \
    && ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone \
    && yum clean all


ADD bin/docker-startup.sh bin/docker-startup.sh
ADD conf/application.properties conf/application.properties


# set startup log dir
RUN mkdir -p logs \
	&& cd logs \
	&& touch start.out \
	&& ln -sf /dev/stdout start.out \
	&& ln -sf /dev/stderr start.out
RUN chmod +x bin/docker-startup.sh

EXPOSE 8848
EXPOSE 9848
EXPOSE 9849
ENTRYPOINT ["bin/docker-startup.sh"]

# docker build -t stud/nacos-server-m1:2.2.3 .

4.修改build/conf内的配置文件application.properties

	这个文件就是对应的配置,不需要再建卷了

5.把build整个放进服务器,执行构建命令

docker build -t stud/nacos-server-m1:2.2.3 

6.通过docker-compose启动(单例)

version: '3'
services:
    nacos:
        restart: always
        image: stud/nacos-server:2.2.3
        container_name: nacos
        ports:
          - 8848:8848
          - 9848:9848
          - 9849:9849
        privileged: true
        volumes:
          - ./logs:/home/nacos/logs
          - ./data:/home/nacos/data

你可能感兴趣的:(docker,容器,运维)