Dockerfile的使用

简介

制作docker镜像可以通过修改容器的方式,也通过通过Dockerfile文件的方式,下面通过Dockerfile文件的例子进行说明。

Dockerfile文件

plain 复制代码
FROM openjdk:8-alpine
    
#ENV http_proxy http://127.0.0.1:7890
#ENV https_proxy http://127.0.0.1:7890
    
#ENV TZ=Asia/Shanghai
#RUN set -eux; \
#    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime; \
#    echo $TZ > /etc/timezone
    
#RUN apk update \
#        && apk upgrade \ 
#        && apk add --no-cache bash \
#        bash-doc \
#        bash-completion \
#        && rm -rf /var/cache/apk/* \
#        && /bin/bash




#RUN echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.4/main/" > /etc/apk/repositories
RUN echo "http://mirrors.ustc.edu.cn/alpine/v3.4/main/"  > /etc/apk/repositories
RUN cat /etc/apk/repositories
 
# 容器内执行
#$RUN rm -fr /var/cache/apk
#RUN mkdir -p mkdir /var/cache/apk


RUN rm -rf /var/cache/apk/* && \
    rm -rf /tmp/*


RUN apk update


ENV TZ=Asia/Shanghai
RUN set -eux; \
    apk add --no-cache  tzdata; \
    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime; \
    echo $TZ > /etc/timezone  




#RUN apk update \
#    && DEBIAN_FRONTEND=noninteractive apt install -y tzdata \
#    && rm -rf /var/lib/apt/lists/*


    
RUN set -eux; \
    addgroup --gid 1000 java-app; \
    adduser -S -u 1000 -g java-app -h /home/java-app/ -s /bin/sh -D java-app;
  


EXPOSE 8080


COPY --chown=java-app firefly  /home/java-app/firefly


ADD docker-entrypoint.sh /home/java-app/firefly/docker-entrypoint.sh


RUN chown -R java-app:java-app  /home/java-app


USER java-app


WORKDIR /home/java-app/firefly


CMD /home/java-app/firefly/docker-entrypoint.sh

精简的Dockerfile文件

plain 复制代码
FROM openjdk:8-alpine
    
RUN echo "http://mirrors.ustc.edu.cn/alpine/v3.4/main/"  > /etc/apk/repositories
RUN cat /etc/apk/repositories
 
RUN rm -rf /var/cache/apk/* && \
    rm -rf /tmp/*

RUN apk update -v
ENV TZ=Asia/Shanghai
RUN set -eux; \
    apk add --no-cache  tzdata; \
    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime; \
    echo $TZ > /etc/timezone  

RUN set -eux; \
    addgroup --gid 1000 java-app; \
    adduser -S -u 1000 -g java-app -h /home/java-app/ -s /bin/sh -D java-app;
  

EXPOSE 8080

COPY --chown=java-app firefly  /home/java-app/firefly

ADD docker-entrypoint.sh /home/java-app/firefly/docker-entrypoint.sh

RUN chown -R java-app:java-app  /home/java-app

USER java-app

WORKDIR /home/java-app/firefly

CMD /home/java-app/firefly/docker-entrypoint.sh

制作镜像命令脚本

plain 复制代码
#!/bin/bash

image=harbor.k8s/firefly/firefly-spring-boot-starter:1.2.0

#docker build -t $image  ./  --build-arg HTTP_PROXY="http://127.0.0.1:7890"  --no-cache

docker build -t $image  ./   --no-cache

#--network=host
#docker build -t $image  ./   --progress=plain --no-cache
#docker push $image

基于elasticsearch基础镜像

elastisearch镜像是基于ubuntu制作的。

plain 复制代码
FROM elasticsearch:7.17.21

RUN apt-get update
RUN apt-get install tzdata


COPY --chown=elasticsearch:elasticsearch jvm.options        /usr/share/elasticsearch/config/
COPY --chown=elasticsearch:elasticsearch elastic-certificates.p12        /usr/share/elasticsearch/config/
COPY --chown=elasticsearch:elasticsearch elastic-stack-ca.p12        /usr/share/elasticsearch/config/



#COPY sysctl.conf  /etc/

#RUN sysctl -w vm.max_map_count=262144

ENV TZ=Asia/Shanghai
RUN set -eux; \
    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime; \
    echo $TZ > /etc/timezone
  

基于filebeat的镜像

plain 复制代码
FROM docker.elastic.co/beats/filebeat:8.13.4
    
USER root	

ENV TZ=Asia/Shanghai
RUN apt-get update
RUN apt-get install tzdata
RUN set -eux; \
    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime; \
    echo $TZ > /etc/timezone  

COPY filebeat-8.13.4-linux-x86_64/ilm.json  /usr/share/filebeat/ilm.json
COPY filebeat-8.13.4-linux-x86_64/template.json  /usr/share/filebeat/template.json

RUN chown -R filebeat:filebeat  /usr/share/filebeat

USER filebeat

制作elasticsearch镜像

plain 复制代码
FROM elasticsearch:7.17.21

RUN apt-get update
RUN apt-get install tzdata


COPY --chown=elasticsearch:elasticsearch jvm.options        /usr/share/elasticsearch/config/
COPY --chown=elasticsearch:elasticsearch elastic-certificates.p12        /usr/share/elasticsearch/config/
COPY --chown=elasticsearch:elasticsearch elastic-stack-ca.p12        /usr/share/elasticsearch/config/



#COPY sysctl.conf  /etc/

#RUN sysctl -w vm.max_map_count=262144

ENV TZ=Asia/Shanghai
RUN set -eux; \
    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime; \
    echo $TZ > /etc/timezone
    


------------------------------------------------------
制作镜像命令
#!/bin/bash

image=harbor.k8s/firefly/elasticsearch:7.17.21

#docker build -t $image  ./  --build-arg HTTP_PROXY="http://127.0.0.1:7890"  --no-cache

docker build -t $image  ./   --no-cache

#--network=host
#docker build -t $image  ./   --progress=plain --no-cache
#docker push $image
 

制作filebeat镜像

基于filebeat官网镜像

plain 复制代码
FROM docker.elastic.co/beats/filebeat:8.13.4
    
USER root	

ENV TZ=Asia/Shanghai
RUN apt-get update
RUN apt-get install tzdata
RUN set -eux; \
    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime; \
    echo $TZ > /etc/timezone  

COPY filebeat-8.13.4-linux-x86_64/ilm.json  /usr/share/filebeat/ilm.json
COPY filebeat-8.13.4-linux-x86_64/template.json  /usr/share/filebeat/template.json

RUN chown -R filebeat:filebeat  /usr/share/filebeat

USER filebeat

基于alpine:3.9.5

plain 复制代码
#FROM openjdk:8-alpine
#FROM hub-dev.paas.jnbank.com.cn/jiangnanbank/kylin-server-tini-jdk:openjdk1.8.0.272
#FROM centos:7 

FROM alpine:3.9.5
    
RUN echo "http://mirrors.ustc.edu.cn/alpine/v3.4/main/"  > /etc/apk/repositories
RUN cat /etc/apk/repositories
 
RUN rm -rf /var/cache/apk/* && \
    rm -rf /tmp/*
RUN apk update -v	
ENV TZ=Asia/Shanghai
RUN set -eux; \
    apk add --no-cache  tzdata; \
    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime; \
    echo $TZ > /etc/timezone  
  
RUN set -eux; \
    addgroup --gid 1000 filebeat; \
    adduser -S -u 1000 -g filebeat -h /usr/share/filebeat -s /bin/sh -D filebeat;
  
RUN mkdir /lib64
RUN ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2   

RUN apk add musl-dev
RUN ln -s /usr/lib/libc.so /usr/lib/libresolv.so.2
  
#USER root
#RUN useradd -m filebeat -d /usr/share/filebeat

COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +rx /usr/local/bin/docker-entrypoint.sh

COPY --chown=filebeat:filebeat filebeat-8.13.4-linux-x86_64/  /usr/share/filebeat/
  
USER filebeat  
WORKDIR /usr/share/filebeat 
ENV PATH=/usr/share/filebeat:/usr/local/bin/:$PATH
#ENTRYPOINT ["docker-entrypoint.sh", "-e", "-strict.perms=false"]
 

基于centos:7 镜像

plain 复制代码
#FROM openjdk:8-alpine
#FROM hub-dev.paas.jnbank.com.cn/jiangnanbank/kylin-server-tini-jdk:openjdk1.8.0.272
FROM centos:7 
  

#RUN set -eux; \
#    addgroup --gid 1000 filebeat; \
#    adduser -S -u 1000 -g filebeat -h /usr/share/filebeat -s /bin/sh -D filebeat;
  
USER root

RUN yum install -y tzdata

RUN useradd -m filebeat -d /usr/share/filebeat

 
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +rx /usr/local/bin/docker-entrypoint.sh

COPY --chown=filebeat:filebeat filebeat-8.13.4-linux-x86_64/  /usr/share/filebeat/
  
USER filebeat  
WORKDIR /usr/share/filebeat 
ENV PATH=/usr/share/filebeat:/usr/local/bin/:$PATH
#ENTRYPOINT ["docker-entrypoint.sh", "-e", "-strict.perms=false"]
 

基于filebeat官方镜像

plain 复制代码
FROM docker.elastic.co/beats/filebeat:8.13.4
     	

COPY filebeat-8.13.4-linux-x86_64/ilm.json  /usr/share/filebeat/ilm.json
COPY filebeat-8.13.4-linux-x86_64/template.json  /usr/share/filebeat/template.json

docker-entrypoint.sh文件

plain 复制代码
#!/bin/sh

set -euo pipefail


if [ "$#" = 0 ];then 
   exec filebeat "$@"
fi 

if [[ -z $1 ]] || [[ ${1:0:1} == '-' ]] ; then
  exec filebeat "$@"
else
  subcommands=$(filebeat help \
                  | awk 'BEGIN {RS=""; FS="\n"} /Available Commands:/' \
                  | awk '/^\s+/ {print $1}')

  for subcommand in $subcommands; do
      if [[ $1 == $subcommand ]]; then
        exec filebeat "$@"
      fi
  done
fi

exec "$@"

制作镜像脚本

plain 复制代码
#!/bin/bash

image=harbor.k8s/firefly/filebeat:8.13.4  

#docker build -t $image  ./  --build-arg HTTP_PROXY="http://127.0.0.1:7890"  --no-cache

docker build -t $image  ./   --no-cache

#--network=host
#docker build -t $image  ./   --progress=plain --no-cache
#docker push $image
 

制作firefly镜像

Dockerfile文件

plain 复制代码
FROM openjdk:8-alpine
    
RUN echo "http://mirrors.ustc.edu.cn/alpine/v3.4/main/"  > /etc/apk/repositories
RUN cat /etc/apk/repositories
 
RUN rm -rf /var/cache/apk/* && \
    rm -rf /tmp/*

RUN apk update -v
ENV TZ=Asia/Shanghai
RUN set -eux; \
    apk add --no-cache  tzdata; \
    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime; \
    echo $TZ > /etc/timezone  

RUN set -eux; \
    addgroup --gid 1000 java-app; \
    adduser -S -u 1000 -g java-app -h /home/java-app/ -s /bin/sh -D java-app;
  

EXPOSE 8080

COPY --chown=java-app firefly  /home/java-app/firefly

ADD docker-entrypoint.sh /home/java-app/firefly/docker-entrypoint.sh

RUN chown -R java-app:java-app  /home/java-app

USER java-app

WORKDIR /home/java-app/firefly

CMD /home/java-app/firefly/docker-entrypoint.sh

docker-entrypoint.sh文件

plain 复制代码
sh /home/java-app/firefly/firefly.sh start

镜像脚本

plain 复制代码
#!/bin/bash

image=harbor.k8s/firefly/firefly-spring-boot-starter:1.2.0

#docker build -t $image  ./  --build-arg HTTP_PROXY="http://127.0.0.1:7890"  --no-cache

docker build -t $image  ./   --no-cache

#--network=host
#docker build -t $image  ./   --progress=plain --no-cache
#docker push $image

制作nginx镜像

Dockerfile文件

plain 复制代码
FROM nginx:latest

# 删除默认的nginx.conf文件
# RUN rm /etc/nginx/nginx.conf

# 将本地的nginx.conf文件复制到容器中
COPY nginx.conf /etc/nginx/
# 复制dist目录到容器中
COPY dist/ /www/

# 暴露8088端口
EXPOSE 8088

# 启动Nginx服务器
CMD ["nginx", "-g", "daemon off;"]

nginx.conf文件

plain 复制代码
# user agree  agree;
worker_processes  1;

#error_log  logs/error.log error;
#error_log  logs/notice.log  notice;
#error_log  logs/info.log  info;

pid        nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       8888;
        #server_name  10.8.4.118;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        #
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location /stub_status {
            stub_status on;
            access_log off;
        }

        location  / {
            root /www/;
            index index.html;
            try_files $uri $uri/ /index.html;
            add_header Access-Control-Allow-Origin *;
	        add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
	        add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
            if ($request_method = 'OPTIONS') {
                return 204;
            }
            if ($request_filename ~* .*\.(?:htm|html)$) {
                add_header Cache-Control 'no-cache';
                add_header Access-Control-Allow-Origin *;
            }
        }

        location /favicon.ico {
            root /www/;
        }
        location /gw/firefly/ {
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header Host $http_host;
                    proxy_set_header Cookie $http_cookie;
                # proxy_set_header X-Real_IP $remote_addr;
                    proxy_set_header X_Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_http_version 1.1;
                    proxy_set_header X-Client-IP $remote_addr;
                    proxy_read_timeout 300s;
                    proxy_cookie_path /firefly /;
                    rewrite ^/gw/firefly/(.*) /firefly/$1 break;
                    proxy_pass http://10.8.4.118:8080;
        }
            
        #     # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #     #
        #     #location ~ \.php$ {
        #     #    proxy_pass   http://127.0.0.1;
        #     #}

        #     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #     #
        #     #location ~ \.php$ {
        #     #    root           html;
        #     #    fastcgi_pass   127.0.0.1:9000;
        #     #    fastcgi_index  index.php;
        #     #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #     #    include        fastcgi_params;
        #     #}

        #     # deny access to .htaccess files, if Apache's document root
        #     # concurs with nginx's one
        #     #
        #     #location ~ /\.ht {
        #     #    deny  all;
        #     #}
    }

    #server {
        #listen       8881;
        #server_name  10.8.4.118;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        #
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        #error_page   500 502 503 504  /50x.html;
        #location = /50x.html {
        #    root   html;
        #}

       # location /stub_status {
        #    stub_status on;
         #   access_log off;
        #}

       # location  / {
       #     root /firefly-afa/;
       #     index index.html;
       #     try_files $uri $uri/ /index.html;
       #     add_header Access-Control-Allow-Origin *;
	#        add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
	#        add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
         #   if ($request_method = 'OPTIONS') {
          #      return 204;
           # }
           # if ($request_filename ~* .*\.(?:htm|html)$) {
           #     add_header Cache-Control 'no-cache';
           #     add_header Access-Control-Allow-Origin *;
           # }
        #}

        #location /favicon.ico {
         #   root /firefly-afa/;
        #}
        #location /firefly-gateway/ {
         #           rewrite ^/firefly-gateway/(.*) /firefly/$1 break;
          #          proxy_pass http://10.8.4.118:8901;
        #}
    #}

    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

命令脚本

plain 复制代码
#!/bin/bash

image=nginx-firefly:latest-1.2.0

docker build -t $image  ./  --no-cache

#docker build -t $image  ./   --progress=plain --no-cache

#docker push $image

制作skywalking oap镜像

Dockerfile文件

plain 复制代码
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you 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.

ARG JAVA_VERSION=8

FROM adoptopenjdk/openjdk$JAVA_VERSION:alpine

RUN echo "http://mirrors.ustc.edu.cn/alpine/v3.4/main/"  > /etc/apk/repositories
RUN cat /etc/apk/repositories
 
RUN rm -rf /var/cache/apk/* && \
    rm -rf /tmp/*

RUN apk update -v
ENV TZ=Asia/Shanghai
RUN set -eux; \
    apk add --no-cache  tzdata; \
    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime; \
    echo $TZ > /etc/timezone  

ENV JAVA_OPTS=" -Xms256M " \
    SW_CLUSTER="standalone" \
    SW_STORAGE="h2"

ARG DIST_NAME
ENV DIST_NAME="apache-skywalking-apm-bin"
COPY "$DIST_NAME.tar.gz" /

RUN set -ex; \
    tar -xzf "$DIST_NAME.tar.gz"; \
    rm -rf "$DIST_NAME.tar.gz"; \
    mv "$DIST_NAME" skywalking;

WORKDIR skywalking

#COPY log4j2.xml config/
COPY docker-entrypoint.sh .
RUN mkdir ext-config; \
    mkdir ext-libs;

EXPOSE 12800 11800 1234

ENTRYPOINT ["sh", "docker-entrypoint.sh"]

docker-entrypoint.sh文件

plain 复制代码
#censed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you 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.

/skywalking/bin/oapService-foreground.sh "$@"

docker-entrypoint.sh文件(版本2)

plain 复制代码
#censed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you 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.

set -e

echo "[Entrypoint] Apache SkyWalking Docker Image"

EXT_LIB_DIR=/skywalking/ext-libs
EXT_CONFIG_DIR=/skywalking/ext-config

# Override configuration files
if [ "$(ls -A $EXT_CONFIG_DIR)" ]; then
  cp -vfRL ${EXT_CONFIG_DIR}/* config/
fi

CLASSPATH="config:$CLASSPATH"
for i in oap-libs/*.jar
do
    CLASSPATH="$i:$CLASSPATH"
done
for i in "${EXT_LIB_DIR}"/*.jar
do
    CLASSPATH="$i:$CLASSPATH"
done

if java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -version; then
  JAVA_OPTS="${JAVA_OPTS} -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
fi

set -ex

exec java ${JAVA_OPTS} -classpath ${CLASSPATH} org.apache.skywalking.oap.server.starter.OAPServerStartUp "$@"

日志输出

默认输出到文件,官方版本默认输出到终端。如果想在文件和终端同时输出,修改日志配置文件conf/log4j2.xml

加上配置

plain 复制代码
<Console name="Console" target="SYSTEM_OUT">
    <PatternLayout charset="UTF-8" pattern="%d - %c -%-4r [%t] %-5p %x - %m%n"/>
</Console>
以及
<AppenderRef ref="Console"/>

完整的配置内容为:

plain 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one or more
  ~ contributor license agreements.  See the NOTICE file distributed with
  ~ this work for additional information regarding copyright ownership.
  ~ The ASF licenses this file to You 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.
  ~
  -->

<Configuration status="info">
    <Properties>
        <Property name="log-path">${sys:oap.logDir}</Property>
    </Properties>
    <Appenders>
        <RollingFile name="RollingFile" fileName="${log-path}/skywalking-oap-server.log"
                     filePattern="${log-path}/skywalking-oap-server-%d{yyyy-MM-dd}-%i.log.gz">
            <PatternLayout>
                <pattern>%d - %c - %L [%t] %-5p %x - %m%n</pattern>
            </PatternLayout>
            <Policies>
                <SizeBasedTriggeringPolicy size="102400KB"/>
            </Policies>
            <DefaultRolloverStrategy max="7">
                <Delete basePath="${log-path}" maxDepth="1">
                    <IfFileName glob="*.log.gz"/>
                    <IfLastModified age="7d" />
                </Delete>
            </DefaultRolloverStrategy>
        </RollingFile>
		
		<Console name="Console" target="SYSTEM_OUT">
            <PatternLayout charset="UTF-8" pattern="%d - %c -%-4r [%t] %-5p %x - %m%n"/>
        </Console>
    </Appenders>

    <Loggers>
        <logger name="org.eclipse.jetty" level="INFO"/>
        <logger name="org.apache.zookeeper" level="INFO"/>
        <logger name="io.grpc.netty" level="INFO"/>
        <Root level="info">
            <AppenderRef ref="RollingFile"/>
			<AppenderRef ref="Console"/>
        </Root>
    </Loggers>
</Configuration>

制作asuperagent镜像

Dockerfile文件

plain 复制代码
FROM alpine:3.9.5
    
ENV TZ=Asia/Shanghai
RUN set -eux; \
    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime; \
    echo $TZ > /etc/timezone
    
    
RUN set -eux; \
    addgroup --gid 1000 agent-app  ; \
    adduser -S -u 1000 -g agent-app   -h /home/agent-app/ -s /bin/sh -D agent-app;
    
RUN mkdir /lib64
RUN ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2     
     
WORKDIR /home/agent-app  
EXPOSE 8972

ADD docker-entrypoint.sh /home/agent-app/docker-entrypoint.sh

COPY asuperagent    /home/agent-app/asuperagent
COPY config.yaml    /home/agent-app/config.yaml


CMD /home/agent-app/docker-entrypoint.sh

docker-entrypoint.sh文件

plain 复制代码
/home/agent-app/asuperagent /home/agent-app/config.yaml

镜像脚本

plain 复制代码
#!/bin/bash

image=harbor.k8s/agree/ada/asuperagent:1.0.0
docker build -t $image  ./
docker push $image
相关推荐
sam-1231 小时前
k8s上部署redis高可用集群
redis·docker·k8s
Fanstay9852 小时前
在Linux中使用Nginx和Docker进行项目部署
linux·nginx·docker
death bell3 小时前
Docker基础概念
运维·docker·容器
天幕繁星5 小时前
docker desktop es windows解决vm.max_map_count [65530] is too low 问题
windows·elasticsearch·docker·docker desktop
想学习java初学者6 小时前
Docker Compose部署Kafka(非Zookeeper)
docker·容器·kafka
尝尝你的优乐美6 小时前
Docker部署Vue项目原来可以那么好用
前端·nginx·docker
迷茫运维路7 小时前
docker搭建Jenkins2.346.3版本及常用工具集成配置(ldap、maven、ansible、npm等)
运维·docker·jenkins·cicd
我叫乐多你养我啊7 小时前
Windows远程连接Docker服务
笔记·docker
mit6.82410 小时前
[Docker#5] 镜像仓库 | 命令 | 实验:搭建Nginx | 创建私有仓库
linux·后端·docker·云原生
牛右刀薛面10 小时前
麒麟V10,arm64,离线安装docker和docker-compose
运维·docker·容器·麒麟·鲲鹏