doukanxi4246 2018-10-26 22:11
浏览 197
已采纳

在Docker容器中设置CPU限制后如何运行Go程序?

I have created a docker container for my Go program and I am able to run that code within that container successfully. I have created a docker network to run that code. I have used the following command:

docker run --network network_name -it go_program Github_repo -l 10000 -secio

Now to test my program I am trying to provide a maximum fixed cpu resource(40%) to the container. I have used the following command to do that:

sudo docker run -it --cpus=".4" ubuntu

But after that when I try to run my program it always says it doesn't recognize the command:

shihab@shihab-VirtualBox:~$ sudo docker run -it --cpus=".4" ubuntu
root@67637cc7edd1:/# sudo docker run --network network_name -it go_program Github_repo -l 10000 -secio
bash: sudo: command not found

How can I solve this issue? Thanks.

  • 写回答

1条回答 默认 最新

  • dougan1205 2018-10-26 22:58
    关注

    Yes , becuase when you run sudo docker run -it --cpus=".4" ubuntu you go into the container , and then you run the second command inside the container which is not working

    Instead you need to just run one command , all in one:

    sudo docker run --network network_name --cpus=".4" -it go_program Github_repo -l 10000 -secio
    

    here I assume that go_program is the docker image containing your go program

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?