Error starting userland proxy: listen tcp4 172.31.43.11:81: bind: cannot assign requested address

I’ve used the following commands to run docker on my EC2 instance:

docker run --gpus all --shm-size 1g -p 172.31.8.218:80:80 -v $volume ghcr.io/huggingface/text-generation-inference:1.1.0 --model-id $model --num-shard $num_shard --max-input-length 4095 --max-total-tokens 1200

In the docker run command above, 172.31.8.218 is the private IPv4 address from my EC2 instance.
Docker runs successfully with above.

Now, I want to run docker run on another IPv4 address. I run the same commands as above just replacing 172.31.8.218 with another IPv4 address, 172.31.43.11. However, the docker run command leads to this error:

docker: Error response from daemon: driver failed programming external connectivity on endpoint zen_turing (977d5b42f7ad88761bf4aff3ff1154ff9a371af5154927d5c8089d2d856a3aa2): Error starting userland proxy: listen tcp4 172.31.43.11:81: bind: cannot assign requested address.
ERRO[0000] error waiting for container:

Could anyone please explain why I’m having this issue? Thanks

You can’t just use any IP in the Docker command, you would need to create the IP on the host/node first.

Thank you. I figured that I need to run the docker run from inside the same instance that I’m trying to build the container for (in this case, the instance for the IPV4 172.31.43.11).