Would bind container port 80 to port 80 on the host’s interface having the ip 10.1.1.2. If the host doesn’t have an interface using this ip, the command should fail.
Seems like what you want is a distinct ip on your lan. Please search the forum for macvlan and how it works.
Thank you for your reply. So, exposing the IP on port 80 works, shall I understand that this command cannot be used for exposing the IP on all ports? I thought -P (capital) would expose all the ports.
docker run -d -p 10.1.1.2:80:80 container_name
Your command actualy publishes port 80 only to the interface with the ip 10.1.1.2. It does not introduce a new ip to your host or your network. Think about it as a filter: instead of binding the port on all existing interfaces, it restricts it to one specific interface.
The option -P will publish all container ports to random ports on all host interfaces. Usualy this is NOT what you want.
If you don’t use docker-compose so far, I would strongly suggest to start using it. It will make your life much easier and your deployments reproducable.
Usualy people that are trying to use docker containers like vm’s (they are not!) tend to use macvlan. Most usecases are achivable with publised ports on bridged (=single host docker network) or overlay (=multi host docker network) networks.