我想替换docker映像中的文本 所以我用ENV代替文字
但是当我将文本放入ENV时,不会覆盖ENV
我的dockerfile
PROMPT ** Creating stored procedure TAHolidayCal_FindBrkCls *********************
CREATE OR REPLACE PACKAGE TAHolidayCal_FindBrkClsPkg AS
TYPE RT1 IS RECORD (
InstrumentID Instrument.InstrumentID%TYPE,
Status Instrument.Status%TYPE,
Product Instrument.Product%TYPE,
SysDescription Instrument.SysDescription%TYPE,
TradeAdminStatus EXTTradeStatus.TradeAdminStatus%TYPE,
PayDate InstCfl.PayDate%TYPE
);
TYPE RCT1 IS REF CURSOR RETURN RT1;
END;
/
CREATE OR REPLACE PROCEDURE TAHolidayCal_FindBrkCls
(
calDate DATE,
holCalID CHAR,
InstID01 CHAR ,InstID02 CHAR DEFAULT NULL,InstID03 CHAR DEFAULT NULL,InstID04 CHAR DEFAULT NULL,InstID05 CHAR DEFAULT NULL,InstID06 CHAR DEFAULT NULL,InstID07 CHAR DEFAULT NULL,
InstID08 CHAR DEFAULT NULL,InstID09 CHAR DEFAULT NULL,InstID10 CHAR DEFAULT NULL,InstID11 CHAR DEFAULT NULL,InstID12 CHAR DEFAULT NULL,InstID13 CHAR DEFAULT NULL,InstID14 CHAR DEFAULT NULL,
InstID15 CHAR DEFAULT NULL,InstID16 CHAR DEFAULT NULL,InstID17 CHAR DEFAULT NULL,InstID18 CHAR DEFAULT NULL,InstID19 CHAR DEFAULT NULL,InstID20 CHAR DEFAULT NULL,InstID21 CHAR DEFAULT NULL,
InstID22 CHAR DEFAULT NULL,InstID23 CHAR DEFAULT NULL,InstID24 CHAR DEFAULT NULL,InstID25 CHAR DEFAULT NULL,InstID26 CHAR DEFAULT NULL,InstID27 CHAR DEFAULT NULL,InstID28 CHAR DEFAULT NULL,
InstID29 CHAR DEFAULT NULL,InstID30 CHAR DEFAULT NULL,InstID31 CHAR DEFAULT NULL,InstID32 CHAR DEFAULT NULL,InstID33 CHAR DEFAULT NULL,InstID34 CHAR DEFAULT NULL,InstID35 CHAR DEFAULT NULL,
InstID36 CHAR DEFAULT NULL,InstID37 CHAR DEFAULT NULL,InstID38 CHAR DEFAULT NULL,InstID39 CHAR DEFAULT NULL,InstID40 CHAR DEFAULT NULL,InstID41 CHAR DEFAULT NULL,InstID42 CHAR DEFAULT NULL,
InstID43 CHAR DEFAULT NULL,InstID44 CHAR DEFAULT NULL,InstID45 CHAR DEFAULT NULL,InstID46 CHAR DEFAULT NULL,InstID47 CHAR DEFAULT NULL,InstID48 CHAR DEFAULT NULL,InstID49 CHAR DEFAULT NULL,
InstID50 CHAR DEFAULT NULL,InstID51 CHAR DEFAULT NULL,InstID52 CHAR DEFAULT NULL,InstID53 CHAR DEFAULT NULL,InstID54 CHAR DEFAULT NULL,InstID55 CHAR DEFAULT NULL,InstID56 CHAR DEFAULT NULL,
InstID57 CHAR DEFAULT NULL,InstID58 CHAR DEFAULT NULL,InstID59 CHAR DEFAULT NULL,InstID60 CHAR DEFAULT NULL,InstID61 CHAR DEFAULT NULL,InstID62 CHAR DEFAULT NULL,InstID63 CHAR DEFAULT NULL,
InstID64 CHAR DEFAULT NULL,InstID65 CHAR DEFAULT NULL,InstID66 CHAR DEFAULT NULL,InstID67 CHAR DEFAULT NULL,InstID68 CHAR DEFAULT NULL,InstID69 CHAR DEFAULT NULL,InstID70 CHAR DEFAULT NULL,
InstID71 CHAR DEFAULT NULL,InstID72 CHAR DEFAULT NULL,InstID73 CHAR DEFAULT NULL,InstID74 CHAR DEFAULT NULL,InstID75 CHAR DEFAULT NULL,InstID76 CHAR DEFAULT NULL,InstID77 CHAR DEFAULT NULL,
InstID78 CHAR DEFAULT NULL,InstID79 CHAR DEFAULT NULL,InstID80 CHAR DEFAULT NULL,InstID81 CHAR DEFAULT NULL,InstID82 CHAR DEFAULT NULL,InstID83 CHAR DEFAULT NULL,InstID84 CHAR DEFAULT NULL,
InstID85 CHAR DEFAULT NULL,InstID86 CHAR DEFAULT NULL,InstID87 CHAR DEFAULT NULL,InstID88 CHAR DEFAULT NULL,InstID89 CHAR DEFAULT NULL,InstID90 CHAR DEFAULT NULL,InstID91 CHAR DEFAULT NULL,
InstID92 CHAR DEFAULT NULL,InstID93 CHAR DEFAULT NULL,InstID94 CHAR DEFAULT NULL,InstID95 CHAR DEFAULT NULL,InstID96 CHAR DEFAULT NULL,InstID97 CHAR DEFAULT NULL,InstID98 CHAR DEFAULT NULL,
InstID99 CHAR DEFAULT NULL,InstID100 CHAR DEFAULT NULL,
RC1 IN OUT TAHolidayCal_FindBrkClsPkg.RCT1
)
AS
BEGIN
OPEN RC1 FOR
SELECT DISTINCT i.InstrumentID, i.Status, i.Product, i.SysDescription, e.TradeAdminStatus, TRUNC(TAHolidayCal_FindBrkCls.calDate) AS PayDate
FROM Instrument i LEFT OUTER JOIN EXTTradeStatus e
ON ( i.InstrumentID = e.InstrumentID ) AND ( i.VersionNumber = e.VersionNumber )
INNER JOIN EXTBreakClause b
ON ( i.InstrumentID = b.InstrumentID ) AND ( i.VersionNumber = b.VersionNumber )
WHERE i.VersionNumber = 0
AND i.InstrumentID in
(
TAHolidayCal_FindBrkCls.InstID01,TAHolidayCal_FindBrkCls.InstID02,TAHolidayCal_FindBrkCls.InstID03,TAHolidayCal_FindBrkCls.InstID04,
TAHolidayCal_FindBrkCls.InstID05,TAHolidayCal_FindBrkCls.InstID06,TAHolidayCal_FindBrkCls.InstID07,TAHolidayCal_FindBrkCls.InstID08,
TAHolidayCal_FindBrkCls.InstID09,TAHolidayCal_FindBrkCls.InstID10,TAHolidayCal_FindBrkCls.InstID11,TAHolidayCal_FindBrkCls.InstID12,
TAHolidayCal_FindBrkCls.InstID13,TAHolidayCal_FindBrkCls.InstID14,TAHolidayCal_FindBrkCls.InstID15,TAHolidayCal_FindBrkCls.InstID16,
TAHolidayCal_FindBrkCls.InstID17,TAHolidayCal_FindBrkCls.InstID18,TAHolidayCal_FindBrkCls.InstID19,TAHolidayCal_FindBrkCls.InstID20,
TAHolidayCal_FindBrkCls.InstID21,TAHolidayCal_FindBrkCls.InstID22,TAHolidayCal_FindBrkCls.InstID23,TAHolidayCal_FindBrkCls.InstID24,
TAHolidayCal_FindBrkCls.InstID25,TAHolidayCal_FindBrkCls.InstID26,TAHolidayCal_FindBrkCls.InstID27,TAHolidayCal_FindBrkCls.InstID28,
TAHolidayCal_FindBrkCls.InstID29,TAHolidayCal_FindBrkCls.InstID30,TAHolidayCal_FindBrkCls.InstID31,TAHolidayCal_FindBrkCls.InstID32,
TAHolidayCal_FindBrkCls.InstID33,TAHolidayCal_FindBrkCls.InstID34,TAHolidayCal_FindBrkCls.InstID35,TAHolidayCal_FindBrkCls.InstID36,
TAHolidayCal_FindBrkCls.InstID37,TAHolidayCal_FindBrkCls.InstID38,TAHolidayCal_FindBrkCls.InstID39,TAHolidayCal_FindBrkCls.InstID40,
TAHolidayCal_FindBrkCls.InstID41,TAHolidayCal_FindBrkCls.InstID42,TAHolidayCal_FindBrkCls.InstID43,TAHolidayCal_FindBrkCls.InstID44,
TAHolidayCal_FindBrkCls.InstID45,TAHolidayCal_FindBrkCls.InstID46,TAHolidayCal_FindBrkCls.InstID47,TAHolidayCal_FindBrkCls.InstID48,
TAHolidayCal_FindBrkCls.InstID49,TAHolidayCal_FindBrkCls.InstID50,TAHolidayCal_FindBrkCls.InstID51,TAHolidayCal_FindBrkCls.InstID52,
TAHolidayCal_FindBrkCls.InstID53,TAHolidayCal_FindBrkCls.InstID54,TAHolidayCal_FindBrkCls.InstID55,TAHolidayCal_FindBrkCls.InstID56,
TAHolidayCal_FindBrkCls.InstID57,TAHolidayCal_FindBrkCls.InstID58,TAHolidayCal_FindBrkCls.InstID59,TAHolidayCal_FindBrkCls.InstID60,
TAHolidayCal_FindBrkCls.InstID61,TAHolidayCal_FindBrkCls.InstID62,TAHolidayCal_FindBrkCls.InstID63,TAHolidayCal_FindBrkCls.InstID64,
TAHolidayCal_FindBrkCls.InstID65,TAHolidayCal_FindBrkCls.InstID66,TAHolidayCal_FindBrkCls.InstID67,TAHolidayCal_FindBrkCls.InstID68,
TAHolidayCal_FindBrkCls.InstID69,TAHolidayCal_FindBrkCls.InstID70,TAHolidayCal_FindBrkCls.InstID71,TAHolidayCal_FindBrkCls.InstID72,
TAHolidayCal_FindBrkCls.InstID73,TAHolidayCal_FindBrkCls.InstID74,TAHolidayCal_FindBrkCls.InstID75,TAHolidayCal_FindBrkCls.InstID76,
TAHolidayCal_FindBrkCls.InstID77,TAHolidayCal_FindBrkCls.InstID78,TAHolidayCal_FindBrkCls.InstID79,TAHolidayCal_FindBrkCls.InstID80,
TAHolidayCal_FindBrkCls.InstID81,TAHolidayCal_FindBrkCls.InstID82,TAHolidayCal_FindBrkCls.InstID83,TAHolidayCal_FindBrkCls.InstID84,
TAHolidayCal_FindBrkCls.InstID85,TAHolidayCal_FindBrkCls.InstID86,TAHolidayCal_FindBrkCls.InstID87,TAHolidayCal_FindBrkCls.InstID88,
TAHolidayCal_FindBrkCls.InstID89,TAHolidayCal_FindBrkCls.InstID90,TAHolidayCal_FindBrkCls.InstID91,TAHolidayCal_FindBrkCls.InstID92,
TAHolidayCal_FindBrkCls.InstID93,TAHolidayCal_FindBrkCls.InstID94,TAHolidayCal_FindBrkCls.InstID95,TAHolidayCal_FindBrkCls.InstID96,
TAHolidayCal_FindBrkCls.InstID97,TAHolidayCal_FindBrkCls.InstID98,TAHolidayCal_FindBrkCls.InstID99,TAHolidayCal_FindBrkCls.InstID100
)
AND TAHolidayCal_FindBrkCls.holCalID in
(
SELECT REGEXP_SUBSTR((extract(value(NHC), 'NotificationHolidayCalendar/text()')).getStringVal(),'[^,]+',1,LEVEL)
FROM table(xmlsequence(extract(XMLType(b.BreakClauseDefn, 1), '/Definitions/BreakDefn/NotificationHolidayCalendar'))) NHC
CONNECT BY REGEXP_SUBSTR((extract(value(NHC), 'NotificationHolidayCalendar/text()')).getStringVal(),'[^,]+',1,LEVEL) IS NOT NULL order by 1
);
END;
/
SHOW ERRORS;
EXECUTE DROP_SYNONYM ('TAHolidayCal_FindBrkCls')
EXECUTE CREATE_SYNONYM ('TAHolidayCal_FindBrkCls')
EXECUTE CREATE_PERMISSIONS ('TAHolidayCal_FindBrkCls')
目标文件:ssl
RUN apt-get update
RUN apt-get install -y nginx
RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf
# Define mountable directories.
VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/certs", "/etc/nginx/conf.d", "/var/log/nginx", "/var/www/html"]
ENV PROXY_PASS http://localhost:3000
ENV SERVER_NAME myserver.com
ENV PEM_PATH /etc/nginx/certs/cert.pem
ENV KEY_PATH /etc/nginx/certs/cert.key
WORKDIR /etc/nginx
RUN rm -f sites-enabled/default
ADD ./sites-available/ssl /etc/nginx/sites-available/ssl
RUN sed -ri 's@PROXY_PASS@'${PROXY_PASS}'@' sites-available/ssl
RUN sed -ri 's@SERVER_NAME@'${SERVER_NAME}'@' sites-available/ssl
RUN sed -ri 's@PEM_PATH@'${PEM_PATH}'@' sites-available/ssl
RUN sed -ri 's@KEY_PATH@'${KEY_PATH}'@' sites-available/ssl
RUN cp -f sites-available/ssl sites-available/default
#RUN ln -s /etc/nginx/sites-available/ssl sites-enabled/default
EXPOSE 80 443
CMD ["nginx"]
我的执行高管
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl on;
ssl_certificate PEM_PATH;
ssl_certificate_key KEY_PATH;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name SERVER_NAME;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
proxy_pass PROXY_PASS;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
当我运行docker image时,应将ssl文件中的docker run -d -e "SERVER_NAME=docker.havehad.kr" --name nginx-ssl -p 443:443 --rm nginx-ssl
替换为'docker.havehad.kr',但没有这样做
它仍然保留为“ myserver.com”
不知道是什么问题
请帮助我
答案 0 :(得分:0)
在处理docker映像时,您有2个不同的上下文: build 上下文(docker build命令)和 run 上下文(docker run命令)。
ENV指令将环境变量设置为value。此值将在构建阶段的所有后续指令所在的环境中使用,并且也可以内联替换为许多值。
ARG指令定义了一个用户可以在其处传递的变量 使用docker build命令构建到构建器的时间 --build-arg =标志。如果用户指定了Dockerfile中未定义的构建参数,则构建输出 警告。
似乎您需要一种方法来更改Dockerfile中使用的变量以更改sed命令。您应该使用参数来实现这一点,并且可以将它们与环境变量组合以在运行时使它们可用(docker run命令)
RUN apt-get update
RUN apt-get install -y nginx
RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf
# Define mountable directories.
VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/certs", "/etc/nginx/conf.d", "/var/log/nginx", "/var/www/html"]
ARG PROXY_PASS=http://localhost:3000
ARG SERVER_NAME=myserver.com
ARG PEM_PATH=/etc/nginx/certs/cert.pem
ARG KEY_PATH=/etc/nginx/certs/cert.key
ENV PROXY_PASS ${PROXY_PASS}
ENV SERVER_NAME ${SERVER_NAME}
ENV PEM_PATH ${PEM_PATH}
ENV KEY_PATH ${KEY_PATH}
WORKDIR /etc/nginx
RUN rm -f sites-enabled/default
ADD ./sites-available/ssl /etc/nginx/sites-available/ssl
RUN sed -ri 's@PROXY_PASS@${PROXY_PASS}@' sites-available/ssl
RUN sed -ri 's@SERVER_NAME@${SERVER_NAME}@' sites-available/ssl
RUN sed -ri 's@PEM_PATH@${PEM_PATH}@' sites-available/ssl
RUN sed -ri 's@KEY_PATH@${KEY_PATH}@' sites-available/ssl
RUN cp -f sites-available/ssl sites-available/default
#RUN ln -s /etc/nginx/sites-available/ssl sites-enabled/default
EXPOSE 80 443
CMD ["nginx"]
并且您可以在构建图像时更改参数值:
$ docker build --build-arg SERVER_NAME=docker.havehad.kr .
您的${SERVER_NAME}
参数将在Dockerfile指令(ENV和RUN)中替换为docker.havehad.kr
。
如果需要在运行时(docker运行)更改sed命令,请将其放入shell脚本中并用作ENTRYPOINT