Skip to main content

Setting Up a Docker Environment on ESXi with Photon OS

··3 mins·
Docker-Compose Docker Esxi
Makoto Morinaga
Author
Makoto Morinaga
A personal notebook for tech notes, coding, and system experiments.
Table of Contents

To run Docker on ESXi, deploy Photon OS on ESXi.

What is Photon OS?
#

Photon OS is an open-source Linux container host optimized for VMware infrastructure. It features:

  • Optimization for VMware hypervisor
  • Container support
  • Package management via tdnf
  • Enhanced security

Since it is optimized for hypervisors, it is expected to have less overhead compared to installing Docker on other Linux distributions.

Downloading Photon OS
#

For ESXi installations, Photon OS provides two options: OVA and ISO files.

  • OVA Import: Pre-installed Photon OS, easily imported into ESXi with kernel tuning applied for ESXi environments. Missing packages can be installed using tdnf.
  • ISO Installation: Traditional Linux installation method.

The OVA file, specifically OVA-hw13_uefi, is chosen for this setup. Downloading Photon OS

Installing Photon OS
#

From the ESXi Web UI, select “Deploy a virtual machine from an OVF or OVA file” and proceed with the installation. The steps primarily involve clicking “Next” until completion.

Initial Login to Photon OS
#

The root password is predefined for OVA installations. On first login, password change is required.

Setting Value
Username root
Password changeme

Initial Configuration
#

Installing Required Packages
#

Install less and sudo:

Terminal
tdnf install less sudo

Setting a Static IP Address
#

Photon OS uses systemd-networkd for network configuration. First, check the network interface name:

Terminal
networkctl list

Create and edit /etc/systemd/network/00-static.network:

/etc/systemd/network/00-static.network
[Match]
Name=eth0

[Address]
Address=192.168.10.11/24

[Network]
DNS=192.168.10.254

[Route]
Gateway=192.168.10.254

Adjust values according to the network environment.

Apply changes:

Terminal
chmod 644 /etc/systemd/network/00-static.network
sed -i -e "s/yes/no/g" /etc/systemd/network/99-dhcp-en.network
systemctl restart systemd-networkd.service
ip a

Setting Timezone
#

Terminal
ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

Setting Hostname
#

Terminal
echo hostname > /etc/hostname

Creating a General User
#

Terminal
useradd -m -G wheel username
passwd username

The user is added to the wheel group, enabling sudo usage.

Configuring Firewall
#

Modify /etc/systemd/scripts/ip4save to allow required ports:

/etc/systemd/scripts/ip4save
-A INPUT -p tcp -m tcp --dport <port> -j ACCEPT

Apply changes:

Terminal
sudo systemctl restart iptables

Configuring SSH
#

Disable root SSH login by modifying /etc/ssh/sshd_config:

/etc/ssh/sshd_config
PermitRootLogin no

Change the default SSH port:

/etc/ssh/sshd_config
Port 50134

Restart SSH service:

Terminal
sudo systemctl restart sshd

For secure access, enable SSH key authentication.

Expanding Disk Space
#

By default, OVA installations allocate 16GB of storage. To expand, shut down the virtual machine, adjust storage in ESXi Web UI, and restart the VM.

Use parted to resize partitions:

Terminal
sudo tdnf install parted
sudo parted
print free
resizepart 2
quit
sudo resize2fs /dev/sda2
df -h

Configuring Docker
#

Enable and start Docker service:

Terminal
sudo systemctl enable docker
sudo systemctl start docker

Verify Docker installation:

Terminal
sudo docker run --rm hello-world
sudo docker rmi hello-world

Installing Docker Compose
#

Download and set up Docker Compose:

Terminal
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod 755 /usr/local/bin/docker-compose

A Docker environment was successfully set up on ESXi using Photon OS.

Related

RDM Configuration on ESXi 6.5/7.0
··2 mins
Rdm Esxi
Updating Realtek NIC Drivers from net51 to net55 on ESXi
··3 mins
Esxi
Setting Up an Internal DNS Server Using NSD and Unbound
··2 mins
Unbound Nsd Linux