docker build Kibana service

1. Create a folder

mkdir kibana
cd kibana
mkdir dockerfile #镜像构建目录
mkdir shell 构建镜像、运行容器相关脚本
mkdir volumes 挂载文件所在目录,一般包括日志、配置、持久化数据

insert image description here

2. Write Dockerfile

cd dockerfile
vim Dockerfile

The content is as follows

FROM kibana:7.4.2
USER Kibana

3. Write the build script

cd ../shell
vim build

add content

#!/bin/bash
DOCKER_PATH=$PWD/../
sudo docker build -f $DOCKER_PATH/dockerfile/Dockerfile  -t kibana:7.4.2 $DOCKER_PATH/dockerfile/

It was originally planned to use Kibana as the image name; but an error was reported during the build,
insert image description here
so the image name cannot have capital letters in it.
Give execution permission

chmod 755 build

build image

./build

insert image description here
View mirrored
docker images
insert image description here
3. Configuration file modification
Enter the volumes directory
Create a config directory to mount the configuration file
mkdir config
Write the configuration file kibana.conf
cd config
vim kibana.yml
Modify the content as follows

server.name: kibana
server.port: 5601
server.host: "0"

i18n.locale: "zh-CN"
# 对应的 elasticsearch服务所在 ip
elasticsearch.hosts: ["http://127.0.0.1:9200"]
xpack.monitoring.ui.container.elasticsearch.enabled: true

4. Write a script to create a container
cd .../.../shell
vim run
The content is

#!/bin/bash
DOCKER_PATH=$PWD/../
port=5601
imageName=kibana
version=7.4.2
sudo docker run -itd  -p ${port}:5601  --name kibana-v /etc/localtime:/etc/localtime  --restart=always ${imageName}:${version} kibana

Give execution permission
chmod 755 run
to create a container and start
it./run
to view the container
docker ps
insert image description here
5. Verify whether it is successful
Enter the host ip in the browser: 5601
insert image description here

Guess you like

Origin blog.csdn.net/weixin_44835704/article/details/120069871