简体   繁体   English

如何将docker exec添加到IBM bluemix容器中

[英]How to docker exec to IBM bluemix containers

I have just started with IBM containers. 我刚开始使用IBM容器。 Now, I want to to docker exec to the container but I found that this is not supported ( link ). 现在,我想停靠exec到容器,但我发现这不支持( 链接 )。

Basically, I had put my source code in the container and now want to install it and update some configurations, For ex: update the ip address provided. 基本上,我已将我的源代码放在容器中,现在想要安装它并更新一些配置,例如:更新提供的IP地址。

I can create an image from the installed docker container and push that to bluemix but still I need to change some configurations. 我可以从已安装的docker容器创建一个映像并将其推送到bluemix,但我仍然需要更改一些配置。

Please suggest me the alternative ways to achieve this. 请建议我实现这一目标的替代方法。

You can ssh to the IBM Container and update files as needed. 您可以根据需要ssh到IBM Container并更新文件。 To ssh to IBM Container you have to pass an ssh public key using the --ssh option. 要ssh到IBM Container,您必须使用--ssh选项传递ssh公钥。 Follow the steps below to create the ssh public/private key pair and run the IBM container: 按照以下步骤创建ssh公钥/私钥对并运行IBM容器:

1) Create a private/public key pair 1)创建私钥/公钥对

# ssh-keygen -t rsa -f cloud.key

This will create 2 files: cloud.key and cloud.key.pub 这将创建2个文件: cloud.keycloud.key.pub

2) Run the IBM container passing the public key, the sample below runs the default ibmnode image (do a cat cloud.key.pub and paste as the ssh argument): 2)运行传递公钥的IBM容器,下面的示例运行默认的ibmnode映像(执行cat cloud.key.pub并粘贴为ssh参数):

# ice run --name my-container --memory 512 --publish 8000 --ssh "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCrpMSm1U0YCvCfFZDOSqKDNZT0fd9TOWQh/jZPFWJu3BTrZuxDM0Mc5Cv6Lw0yYC5ZdqFsn4Rp4ovCkEY3JsnrE6NSsyrtxMvCGm1FDWYMJBnB4tDoWFmAULYKvdospozjk9Abvl2Hw3xu36j2c3W/x4iB/Xez0xdqNi8YN23gg8n45ZDCsDVZ4SE2ks8u81CoDcDhA3XmJF5Fpfwfnxi7OI9LNTkNJ26CnQb0/k80gYc1qUcGjgPasbWHPuPY4YJDAAr5U6faZUX8IqepLmk/icIQw+SFBQa4OS5+n4jJ3YpkM23RZdylY61t9ltU8GJI/d5tRsV7ZYeX+gE/RO53 xxxxx@xxx.yyy.com" registry.ng.bluemix.net/ibmnode:latest

3) Bind a public IP address to IBM container: 3)将公共IP地址绑定到IBM容器:

# ice ip bind <ip-address> my-container

4) Run ssh command to login to the IBM Container passing private key 4)运行ssh命令以登录到IBM Container传递私钥

# ssh -i cloud.key root@<ip-address>

Since docker run is supported, included with volumes, you could consider adding a data volume . 由于支持docker run (包含在卷中),因此可以考虑添加数据卷

That way, you can modify a file from the host, and the container will see the modification through the mounted volume. 这样,您可以从主机修改文件,容器将通过已安装的卷查看修改。

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

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