User Tools

Site Tools


esxi:docker_host

This is an old revision of the document!


Table of Contents

Docker Host

Setup

Setup Docker on Photon OS on ESXi, and install Portainer and Unifi Controller.

Setup minimal installed profile of PhotonOS

  • Download the latest Photon OS OVA with virtual hardware v15 from https://github.com/vmware/photon/wiki/Downloading-Photon-OS
  • In ESXi:
    • Create/Register VM:
      • Deploy a virtual machine from an OVF or OVA file
      • Name the VM
      • Upload the Photon OS OVA file
      • Specify the desired Target Datastore
      • Accept the License Agreement
      • Deselect Power on automatically
      • Confirm settings and Finish
    • Wait for the files to upload
    • If autostart is desired for this machine go to Host > Manage > System > Autostart:
      • Click on the current VM
      • Enable
      • Use Start earlier and Start later to set the desired order
    • Go to Virtual Machines on the sidebar and click on the current VM
    • Actions > Edit Settings:
      • Set the required CPU and Memory requirements
      • If using NVMe storage for the datastore:
        • Add other device > NVMe controller
        • Hard Disk 1 > Controller location > NVMe controller 0
        • Save and reopen Edit Settings
        • Remove SCSI controller 0
      • Select other appropriate VM settings depending on desired applications
    • Power on the VM, then shut it down again to generate a MAC address
    • Give the VM a static IP address from your router using the generated MAC address (found under Hardware Configuration > Network adapter 1) and desired hostname
    • Power on the VM
    • Using an SSH client, connect to the hostname set above, then run:
# Login with root details from the VM note
# Follow instructions to set new password
 
# Remove docker related packages if not needed to save space and faster updates
tdnf erase containerd docker docker-cli docker-engine
 
# Update packages:
tdnf upgrade
tdnf clean all
 
# Disable password expiry:
chage -M -1 root
 
# Set new hostname:
hostnamectl set-hostname <hostname-as-set-in-router>
 
# Set the timezone to Perth
ln -sf /usr/share/zoneinfo/Australia/Perth /etc/localtime
 
# Change the SSH port to 50001:
sed -i "s/#Port 22/Port 50001/" /etc/ssh/sshd_config
sed -i "s/-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT/-A INPUT -p tcp -m tcp --dport 50001 -m state --state NEW -j ACCEPT/" /etc/systemd/scripts/ip4save
 
exit
  • Shut down the VM
  • Edit VM note to be the following:
Minimal installed profile of PhotonOS
User: root

Ports:
50001/tcp SSH
  • Save a snapshot called Base Install
2020/05/18 18:24 · derek

Then set up Portainer and Unifi Controller:

  • Power on the VM
  • Using a SSH client, connect to <hostname>:50001 then run:
# Enable Docker to run at startup:
systemctl enable docker
# Install Portainer:
docker volume create portainer_data
docker run --name Portainer --restart=always -d -p 8000:8000 -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
exit
  • Open portainer at http://docker.example.com:9000:
    • Create account
    • Install the Unifi Controller:
      • Set up a Docker Host first
      • Navigate to Portainer
      • Click on the local endpoint
      • Click on containers
      • Add new container
      • Name > Unifi Controller
      • Image > jacobalberty/unifi:latest
      • Add network ports:
        • 8080/tcp - Device command/control
        • 8443/tcp - Web interface + API
        • 8843/tcp - HTTPS portal
        • 8880/tcp - HTTP portal
        • 8883/tcp - Remote Access service
        • 3478/udp - STUN service
        • 6789/tcp - Speed Test (unifi5 only)
        • 10001/udp - UBNT Discovery
      • Add Volume mapping:
        • container > /unifi
        • bind
        • host > /root/unifi
      • Add Environment variables:
        • JVM_MAX_THREAD_STACK_SIZE > 1280k
        • TZ > <Timezone of server>
      • Restart policy > Unless stopped
      • Deploy the container
      • Set the Unifi Controller entry to the IP address of the Unifi controller under the Services > DHCP Server > Details screen for any EdgeRouters that host Unifi devices that wish to be connected to the controller.
      • Access the controller at https://docker.example.com:8443
      • Login/Create a Unifi Account
      • Setup Site settings
      • Reset (if needed) and adopt the Unifi devices
      • FIXME: Add more controller setup
      2019/09/18 06:21 · derek
  • Shutdown, Save Configured snapshot, and start the VM again
  • Edit VM note to add the following:
Docker host:
Portainer:
8000/TCP, 9000/TCP http Web Interface
http://<server.example.com>:9000
User: <User>

Unifi Controller:
10001/udp, 3478/udp
6789/tcp, 8080/tcp
8443/tcp https Web Portal
8843/tcp, 8880/tcp
https://<server.example.com>:8443
User: <User>
  • FIXME: Add network mounts

Update

Update the OS

Run systemctl enable docker after updating to re-enable docker starting on boot

  • If desired, Log in to ESXi, navigate to the photon based VM and create new temporary snapshot
  • Using an SSH client, connect to <hostname>:50001 then run:
tdnf upgrade
tdnf clean all
reboot  # If desired/needed
2020/05/18 18:24 · derek

Update Portainer

Reconnect and run:

# Update the Portainer image:
docker pull portainer/portainer-ce
# If it responds with:
# Status: Downloaded newer image for portainer/portainer-ce:latest
# then run the following to update the container
docker stop Portainer
docker rm Portainer
docker run --name Portainer --restart=always -d -p 8000:8000 -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
esxi/docker_host.1610870650.txt.gz · Last modified: 2024/09/22 19:51 (external edit)