如何在 docker 镜像中包含修改后的配置文件? [英] How to include modified configuration files in a docker image?
问题描述
我是 Docker 新手.一位 devop 同事在 github 存储库中创建了一个 WSO2 docker 映像.他使用这些图像来创建登台和生产实例.
I am new to Docker. A devop colleague has created a WSO2 docker image in a github repository. He uses such images to create staging and production instances.
docker-compose.yml
是:
#openssl req -newkey rsa:2048 -nodes -keyout domain.key -x509 -days 365 -out domain.crt
version: '2'
services:
mysql:
image: mysql:5.7.10
ports:
- "3306:3306"
volumes:
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
environment:
- MYSQL_DATABASE=userdb
- MYSQL_USER=dbwso2am
- MYSQL_PASSWORD=dbwso2am
- MYSQL_ROOT_PASSWORD=dbwso2am
wso2am:
image: salte/wso2am:1.9.1
depends_on:
- mysql
volumes:
- ./keys:/keys
environment:
- VIRTUAL_HOST=apimanager.qa.xxx.build
- VIRTUAL_PORT=9443
- VIRTUAL_PROTO=https
- OFFSET=3
- EXTERNAL_HOSTNAME=apimanager.qa.xxx.build
- DATABASE_HOSTNAME=mysql
- DATABASE_PORT=3306
- DATABASE_USER=dbwso2am
- DATABASE_PASSWORD=dbwso2am
- PUBLIC_CERTIFICATE=/keys/domain.crt
- PRIVATE_KEY=/keys/domain.key
- PRIVATE_KEY_PASSWORD=wso2am
- ADMIN_PASSWORD=admin
我想修改一些 WSO2 配置 存储在一些 xml
文件并将其推送到生产环境.
I would like to modify some WSO2 configuration stored in some xml
file and push it to production.
我应该如何进行?这可能吗?我应该修改 docker 镜像吗?如果是怎么办?或者我应该将 WSO2 安装在经典的 github 存储库中,在那里修改 xml
并根据该存储库的内容重新创建一个 docker 映像?
How should I proceed? Is this possible? Should I modify the docker image? If yes how? Or should I install WSO2 in a classic github repository, modify the xml
there and re-create a docker image based on this repository's content?
推荐答案
你不需要为了改变一个xml而重新创建整个图像.您可以通过卷或命令替换它.例如,我已链接共享文件夹,您可以在容器上运行命令.假设您在/home/share 中有 Share 文件夹,并且它链接到/c/Share因此,您将新的 xml 文件放入 Share 中,容器也可以看到它.接下来你运行这个命令:
You don't need to create anew the entire image just to change one xml. You can replace it through volumes or command. For example i have linked shared folder and you can run commands on the container. Let say you have Share folder in /home/share and its linked to /c/Share So you put your new xml file in Share and the container can see it too. Next you run this command:
docker exec a5866aee4e90 cp -i /home/share/some.xml /home/the/path/you/chose
Docker exec 用于运行命令.您可以使用以下命令进入控制台并运行多个命令:
Docker exec is used to run commands. You can enter the console and run multiple commands with this:
docker exec -it a5866aee4e90 bash
这篇关于如何在 docker 镜像中包含修改后的配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!