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

How to assign an IP address to docker

Release: 2020-03-30 13:18:24
Original
4464 people have browsed it

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
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template