简体   繁体   English

构建一个包含 Maven settings.xml 的 Docker 镜像 - 这是一种不好的做法吗?

[英]Build a Docker Image with a Maven settings.xml in it - Is it a Bad Practice?

We have this use case where we want to run acceptance tests on our application with maven.我们有这个用例,我们想用 maven 在我们的应用程序上运行验收测试。 For this we are looking into building our docker image with maven settings.xml copied into it.为此,我们正在研究将 maven settings.xml 复制到其中来构建我们的 docker 镜像。 Obviously, the settings xml contains sensitive data about connection to remote artefact repos etc. I am in a dilemma, whether we should copy it in the docker image, or is it a bad practice and we should be looking into other ways to achieve this.显然,设置 xml 包含有关连接到远程人工制品存储库等的敏感数据。我处于两难境地,我们是否应该将它复制到 docker 映像中,或者这是一种不好的做法,我们应该寻找其他方法来实现这一点。

Edit - Another point, our docker images are pushed to private registries which are accessible only to authorised users编辑 - 另一点,我们的 docker 镜像被推送到只有授权用户才能访问的私有注册表

There's absolutely no security around the contents of a Docker image. Docker 镜像的内容绝对没有安全性。 Anyone who gets the image can trivially read its docker history and read or copy arbitrary files out of the image.任何获得图像的人都可以轻松读取其docker history并从图像中读取或复制任意文件。

As such I'd try very hard to keep credentials out of my Docker image build process entirely.因此,我会非常努力地将凭据完全排除在我的 Docker 映像构建过程之外。 If the settings.xml file has usernames and passwords in it, it's much better to find a different way to do the setup required.如果settings.xml文件中包含用户名和密码,那么最好找到一种不同的方式来完成所需的设置。 Similarly, adding an ssh private key, AWS credentials, or a GitHub access token to an image will compromise those credentials.同样,向映像添加 ssh 私有密钥、AWS 凭证或 GitHub 访问令牌将危及这些凭证。

If the settings.xml file only contains internal hostnames (but not credentials), or if the password is intentionally bad, it's a question of how much risk you're willing to tolerate.如果settings.xml文件只包含内部主机名(但不包含凭据),或者密码是故意损坏的,那么问题在于您愿意承受多大的风险。 If you have a URL like http://build:passw0rd@build.internal.example.com where that internal hostname isn't externally accessible, you could argue that's "enough" security given the very guessable username and password and you don't need to go out of your way to hide it, especially if you think you can trust your end users.如果您有一个类似http://build:passw0rd@build.internal.example.com的 URL,其中该内部主机名不能从外部访问,您可能会争辩说,鉴于用户名和密码非常容易猜测,这已经“足够”安全了,而您却没有无需特意隐藏它,尤其是当您认为可以信任最终用户时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM