Home >Operation and Maintenance >Docker >How to assign an IP address to docker

How to assign an IP address to docker

尚
Original
2020-03-30 13:18:244542browse

How to assign an IP address to docker

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn