Configuring Docker Containers with Static IPs on CentOS 7 Using Pipework and a Linux Bridge

To assign a static IP address to a Docker container on CentOS 7 using pipework, begin by setting up a Linux bridge.

First, modify the physical interface configuration to attach it to a bridge. Edit /etc/sysconfig/network-scripts/ifcfg-ens33:

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=ens33
DEVICE=ens33
ONBOOT=yes
BRIDGE=br0

Next, create the bridge interface configuration at /etc/sysconfig/network-scripts/ifcfg-br0:

TYPE=Bridge
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPADDR=192.168.1.151
GATEWAY=192.168.1.1
PREFIX=24
DNS1=114.114.114.114
DEVICE=br0
ONBOOT=yes

Key points:

  • TYPE=Bridge is required for the bridge enterface.
  • BOOTPROTO=static enables manual IP assignment.
  • BRIDGE=br0 in the physical interface links it to the bridge.

After saving both files, activate the bridge without restarting the entire network stack:

ifup br0

Install bridge-utils if not present:

yum install -y bridge-utils

Verify the bridge and its attached interfaces:

brctl show

Expected output should list ens33 under br0.

Proceed to install pipework:

yum install -y git
git clone https://github.com/jpetazzo/pipework.git
cp pipework/pipework /usr/local/bin/

Launch a container in detached mode:

docker run -itd --name="host-152" lys/v1.0 /bin/bash

Assign a static IP on the bridge subnet using pipework:

pipework br0 host-152 192.168.1.152/24@192.168.1.1

This command creates a veth pair: one end attaches to br0, the other appears in side the container as eth1 with the specified IP and gateway.

Confirm the new interface inside the container:

docker exec -it host-152 ip addr show

The output will include an additional interface (eth1) with the assigned static IP 192.168.1.152/24.

Tags: docker CentOS7 pipework networking linux-bridge

Posted on Wed, 04 Nov 2026 16:44:28 +0000 by shumway