How to specify parameter variables externally in docker

How to specify parameter variables externally in docker

This article mainly introduces how to specify parameter variables externally in Docker. The example code in this article is very detailed and has a certain reference value for everyone's study or work. Friends in need can refer to it.

Dockerfile:

FROM frolvlad/alpine-oraclejre8:slim
VOLUME /tmp
ADD app.jar /app.jar
#COPY agent/ /usr/local/skyagent/
WORKDIR /opt
COPY docker-entrypoint.sh .
ENV AP_ENV=$AP_ENV

EXPOSE 7015

ENV JAVA_OPTS=$JAVA_OPTS
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]

Give variables in configuration: application.properties

sea=${sea123}
shan=${shan123}

For Test:

@RestController
public class WebController {
  @Value("${sea}")
  private String sea;
  @Value("${shan}")
  private String shan;  
  @GetMapping("/sea")
  public String test() {
    return sea+shan;
  }
}

Run the image:

sudo docker run -it -p 9999:9999 -e 'sea=sea_test' -e 'shan=shan_test' testproperties004

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Docker: Modifying the DOCKER_OPTS parameter in /etc/default/docker does not take effect
  • Implementation of modifying configuration files in Docker container
  • How to view the IP address of the Docker container
  • The whole process of deploying .net Core project using Docker on Linux server
  • Detailed installation and use of RocketMQ in Docker
  • Docker private repository management and deletion of images in local repositories
  • Example of how to upload a Docker image to a private repository
  • Detailed explanation of how to solve the problem that the docker container cannot access the host machine through IP

<<:  A brief discussion on the pitfalls of react useEffect closure

>>:  MySQL 8.0.13 manual installation tutorial

Recommend

When the interviewer asked the difference between char and varchar in mysql

Table of contents Difference between char and var...

A brief talk about React Router's history

If you want to understand React Router, you shoul...

How to start tomcat using jsvc (run as a normal user)

Introduction to jsvc In production, Tomcat should...

Teach you how to use vscode to build a react-native development environment

question The code has no prompt: Many non-front-e...

Detailed explanation of JavaScript function this pointing problem

Table of contents 1. The direction of this in the...

mysql8.0 windows x64 zip package installation and configuration tutorial

MySQL 8 Windows version zip installation steps (d...

Detailed explanation of custom configuration of docker official mysql image

In order to save installation time, I used the of...

Example code for implementing background blur effect with CSS

Is it the effect below? If so, please continue re...

Enterprise-level installation tutorial using LAMP source code

Table of contents LAMP architecture 1.Lamp Introd...

Pure js to achieve the effect of carousel

This article shares the specific code of js to ac...

Nodejs implements intranet penetration service

Table of contents 1. Proxy in LAN 2. Intranet pen...

Brief analysis of mysql scheduled backup tasks

Introduction In a production environment, in orde...

Solution to the problem of eight hours difference in MySQL insertion time

Solve the problem of eight hours time difference ...

MySQL 8.0 upgrade experience

Table of contents Preface 1. First completely uni...

Nginx configuration based on multiple domain names, ports, IP virtual hosts

1. Type introduction 1.1 Domain-based virtual hos...