从docker容器运行docker命令(Running docker command from docker container)
需要编写一个在dock-a中安装docker的Dockerfile。 因为container-a需要执行docker命令到container-b,它与container-a一起运行。 我的理解是你在编写Dockerfile时不应该使用“sudo”。 但我陷入困境 - 我指派给docker组的用户是什么? 当您运行
docker exec -it
,您将自动为root。
sudo usermod -a -G docker whatuser?
另外(我在集装箱内手动尝试这个 - 看它是否有效)你必须做一个
newgrp docker
来激活对组的更改。 我这样做的任何时候,当我没有sudo'ed时,我最终sudo'ing。 那有意义吗? 症状是 - 我去exit
容器,我必须退出两次(好像我改变了用户)。我究竟做错了什么?
Need to write a Dockerfile that installs docker in container-a. Because container-a needs to execute a docker command to container-b that's running alongside container-a. My understanding is you're not supposed to use "sudo" when writing the Dockerfile. But I'm getting stuck -- what user to I assign to docker group? When you run
docker exec -it
, you are automatically root.
sudo usermod -a -G docker whatuser?
Also (and I'm trying this out manually inside container-a to see if it even works) you have to do a
newgrp docker
to activate the changes to groups. Anytime I do that, I end up sudo'ing when I haven't sudo'ed. Does that make sense? The symptom is -- I go toexit
the container, and I have to exit twice (as if I changed users).What am I doing wrong?
原文:https://stackoverflow.com/questions/42237352
满意答案
使用
const_cast
修改const
数据结构中的数据确实是未定义的行为。 例外情况是标记为mutable
项目。 这些值的重点在于,即使对象的其余部分是const
,它们也是可修改的。 它的确意味着“但这个不是const
”。由于几乎所有的
const
都是关于编译器检测修改的,尽管从技术上讲,编译器允许在“不可写的内存”中放置一些const
变量。mutable
关键字允许“绕过”const
,因此编译器不会将const
对象放入不可写的内存中(如果它有可变组件),当然,它不会“对象”到const
在它的可变组件中修改的对象 - 甚至在const
函数内部。Using
const_cast
to modify data in aconst
data structure is indeed undefined behaviour. The exception is items markedmutable
. The whole point of these values are that they are modifiable even when the rest of the object isconst
. It really means "but this one is notconst
".Since nearly all of
const
is about the compiler detecting modification, although technically, the compiler is allowed place someconst
variables in "non-writeable memory". Themutable
keyword is there to allow "bypass" of the constness, so the compiler will NOT put aconst
object into memory that is non-writeable if it has a mutable component, and of course, it won't "object" toconst
objects being modified in it's mutable components - even inside aconst
function.
相关问答
更多const引用非const对象(const reference to non-const object)
之前的const还是const之后?(Const before or const after?)
当容器在C ++中是const时,如何对容器持有的对象进行非const访问(How to have non-const access to object held by a container when the container is const in C++)
Const和非const c ++构造函数(Const and non-const c++ constructor)
当函数接受对象的引用(并访问非const方法)时,如何抛弃const'ness?(How do you cast away const'ness when the function takes a reference to the object (and access non-const methods)?)
将相同的对象作为const和非const引用传递(Pass same object as const and non-const reference)
修改const对象的非const成员(Modifying non-const members of const object)
将const成员函数转换为非const(Cast const member function to non-const)
constexpr对非const对象的引用(constexpr reference to non-const object)
在const对象上间接调用非const函数(Indirectly calling non-const function on a const object)
相关文章
更多Docker 容器创建并运行MySQL
揭开Docker神秘的面纱-传智播客Docker视频教程
storm client command
《Windows 命令行详解手册(第2版)》(Windows Command-Line Administrator's Pocket Consultant, 2nd Edition)扫描版[PDF]
bash: scp: command not found的解决方法
Running Solr with Maven
solr 建立索引 命令
Shell命令格式
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!