在Docker中禁用交互模式 [英] disable interactive mode in docker
问题描述
在推送/发布/共享docker镜像之前,我想禁用交互模式或在容器中进行密码保护登录。
Before pushing/publishing/sharing a docker image, I would like to disable interactive mode or password protect logging in the container. Is there a option to do so?
用例是,只能以分离模式从docker run或exec运行应用程序
The use case is that one can run app from docker run or exec in detach mode only
docker exec -d ubuntu_bash touch /tmp/execWorks
但是不能做
docker run -ti ubuntu bash
到目前为止,我在docker文档中找不到它。
I could not find it in the docker docs so far.
推荐答案
一种解决方案是从图像中完全删除外壳:
One solution would be to completely remove shell from the image:
docker exec :id -it /bin/rm -R /bin/*
在Linux中摆脱了sh和任何bin有用的命令。我不知道此时是否有可能重新获得访问权限。要记住的另一个方面是,您也许可以使用内存调试器来获取正在运行的容器的环境变量,但这会使难度变得更大。
That gets rid of sh and any bin useful command in linux. I do not know if it is possible to regain access at this point. Another aspect to keep in mind is that you might be able to use a memory debugger to get environment variables of the running container, but it makes it that much more difficult.
最后但并非最不重要的一点是,如果您想保留用户的敏感信息并允许某种访问权限签出:
Last but not least if you would like to keep sensitive information from users and allow some kind of access check out:
> https://docs.docker.com/engine/swarm/secrets/
这篇关于在Docker中禁用交互模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!