如何在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映像吗?如果是,怎么办?还是应该在经典的github存储库中安装WSO2,在那里修改 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屋!