Assign a fixed IP address to docker:
1. Build a network card
#This default is to create a Bridge, if you need a bridge The network card is not the first one (eth0 or something). Please use -o parent=eth1 to specify your network card. You can also use –internal to limit possible external network access.
docker network create --subnet=192.168.1.0/24 --gateway=192.168.1.1 docker-intranet
2. Specify on the container Network card and IP
sudo docker run --name postgres1 --net=docker-intranet --ip=192.168.1.3 -e POSTGRES_PASSWORD=password -p 5433:5432 -d postgres:9.4
When starting Docker, use the --network parameter to specify the network type.
For more related tutorials, please pay attention to the docker tutorial column on the PHP Chinese website.
The above is the detailed content of How to assign an IP address to docker. For more information, please follow other related articles on the PHP Chinese website!