Docker – 设置环境变量

设置环境变量

--env 或者-e指定docker的环境变量 key=value

docker run -e POSTGRES_USER='postgres' -e POSTGRES_PASSWORD='密码' ... docker run --env env=dev -d -p 8888:8080 balance docker run -e spring.datasource.url='jdbc:mysql://10.0.0.17:3306/laker' -d -p 8080:8080 lak er-java:v1 

查看环境变量

方式一 docker inspect 命令来查看

docker inspect 容器id 

Docker – 设置环境变量插图

如果是Windows的话可以用可视化界面,原理一样。

Docker – 设置环境变量插图1

方式二 docker exec 容器id env

PS C:\laker\laker\easy-admin> docker exec 0d9f644cdce8 env PATH=/usr/local/openjdk-8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOSTNAME=0d9f644cdce8 spring.datasource.url=jdbc:mysql://10.140.201.17:3306/laker?serverTimezone=GMT%2B8&characterEncoding=utf8&useSSL=false JAVA_HOME=/usr/local/openjdk-8 LANG=C.UTF-8 JAVA_VERSION=8u342 HOME=/root 

原文链接:https://blog.csdn.net/abu935009066/article/details/127668740?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522171836840916800197020748%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=171836840916800197020748&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-12-127668740-null-null.nonecase&utm_term=docker%E3%80%81%E5%A5%BD%E7%94%A8

© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享