Shihab Shahriar
Shihab Shahriar

Reputation: 31

How to run Go program after making a CPU limit in a docker container?

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.

Upvotes: 2

Views: 128

Answers (1)

Ijaz Ahmad
Ijaz Ahmad

Reputation: 12110

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

Upvotes: 2

Related Questions