Configuring Docker 17.09.0-ce to Start with a Custom Network Address
Prerequisites
A virtual machine running CentOS 7 is required for this setup.
Installing Docker 17.09.0-ce
-
Remove Existing Docker Components
- Uninstall any previously installed Docker packages:
yum remove docker\* - Remove the container-selinux package to avoid conflicts:
yum remove container-selinux-1.12.5-14.el7.centos.x86_64
- Uninstall any previously installed Docker packages:
-
Set Up Docker Repository
- Install yum-utils for repository management:
sudo yum install -y yum-utils - Add the official Docker CE repository:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo - Update the package cache:
sudo yum makecache fast
- Install yum-utils for repository management:
-
Install Docker CE
- List availible Docker CE versions:
yum list docker-ce.x86_64 --showduplicates | sort -r - Enstall Docker CE version 17.09.0:
sudo yum -y install docker-ce-17.09.0.ce
- List availible Docker CE versions:
-
Start Docker and Verify Installation
- Start the Docker service:
systemctl start docker - Enable Docker to start on boot:
systemctl enable docker - Check the Docker version and info:
docker info
- Start the Docker service:
Configuring Docker Startup Parameters
Examine the Docker service file to understand its configuration:
cat /lib/systemd/system/docker.service
The key paramter for customization is ExecStart in the [Service] section. This defines the command executed when starting Docker.
To modify the network address and other settings, update the ExecStart line. Below is an example configuration with custom parameters:
ExecStart=/usr/bin/dockerd --bip=172.18.0.1/16 -H tcp://0.0.0.0:5257 -H unix:///var/run/docker.sock --pidfile=/var/run/docker.pid
Parameter Explanation:
--bip=172.18.0.1/16: Sets the bridge IP address for container networking.-H tcp://0.0.0.0:5257: Configures Docker to listen on TCP port 5257 for remote connections.-H unix:///var/run/docker.sock: Specifies the Unix socket for local Docker communication.--pidfile=/var/run/docker.pid: Defines the location for the Docker daemon's PID file.
For a full list of available options, run:
dockerd --help
Applying Configuration Changes
- Stop the Docker service:
systemctl stop docker - Reload the systemd configuration to apply changes:
systemctl daemon-reload - Start Docker with the new settings:
systemctl start docker