# Setting up the UniFi Network Controller using Docker

[https://pimylifeup.com/unifi-docker/](https://pimylifeup.com/unifi-docker/)

[https://community.ui.com/questions/How-To-Unifi-Contoller-Docker-home-network/fc6a9441-94b0-48b0-801a-6f38e2d4bb21](https://community.ui.com/questions/How-To-Unifi-Contoller-Docker-home-network/fc6a9441-94b0-48b0-801a-6f38e2d4bb21)

Once you have Docker installed, our next step is to prepare your system to run the UniFi Network Controller container.

The main thing we need to do here is create a directory to store the UniFi containers Compose file and all of its data.

You can create this directory by running the following command within the terminal.

```
```bash
sudo mkdir -p /opt/stacks/unifi
```<a class="copy-code-block fa-copy" href="https://pimylifeup.com/unifi-docker/#copy">Copy</a>
```

By utilizing the “`-p`” option, this command will create any missing directories in the given path.

**5.** After creating a directory to store our Compose file, we can change to the directory [by using the cd command](https://pimylifeup.com/cd-command/).

```
```bash
cd /opt/stacks/unifi
```<a class="copy-code-block fa-copy" href="https://pimylifeup.com/unifi-docker/#copy">Copy</a>
```

### Writing a Compose file for the UniFi Docker Container

**6.** Our next step is writing the Compose file for the UniFi docker container. This Compose file will instruct Docker what image to download and the environment variables to pass through to it.

You can begin writing this file by typing in the following command.

```
```bash
sudo nano compose.yaml
```<a class="copy-code-block fa-copy" href="https://pimylifeup.com/unifi-docker/#copy">Copy</a>
```

**7.** Within this file, you will want to type in the following lines.

You must replace “`<TIMEZONE>`” with a valid TZ Identifier. You can find a list of [time zone identifiers from Wikipedia](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).

For example, we would use “`Australia/Hobart`” for our time zone.

```
```yaml
services:
  unifi:
    user: unifi
    image: ghcr.io/jacobalberty/unifi-docker
    container_name: unifi-controller
    restart: unless-stopped
    ports:
      - "8080:8080"
      - "8443:8443"
      - "3478:3478/udp"
      - "10001:10001/udp"
    environment:
      TZ: "<TIMEZONE>"
    volumes:
      - ./data:/unifi
```<a class="copy-code-block fa-copy" href="https://pimylifeup.com/unifi-docker/#copy">Copy</a>
```

**8.** Once you have written the lines above, save and quit by pressing <kbd>CTRL</kbd> + <kbd>X</kbd>, followed by <kbd>Y</kbd>, and then the <kbd>ENTER</kbd> key.

### Starting the UniFi Docker Container

**9.** With the Compose file written, all you need to do to bring the UniFi network controller Docker container online is to use the following command.

We use the “`-d`” option to detach from the current terminal session once the container has started.

```
```bash
docker compose up -d
```<a class="copy-code-block fa-copy" href="https://pimylifeup.com/unifi-docker/#copy">Copy</a>
```

### Accessing the UniFi Network Controller Web Interface

**10.** Now that you have the Docker container for the UniFi network controller running, you will want to access its web interface. You will also need to know the IP address later in this guide.

If you don’t know the local IP address of your machine, you can get it by running the following command.

```
```bash
hostname -I
```<a class="copy-code-block fa-copy" href="https://pimylifeup.com/unifi-docker/#copy">Copy</a>
```

Ensure you set up your device with a static IP address before proceeding further. You do not want your UniFi controller to be assigned a dynamic IP address.

**11.** Once you know the IP address of your device, go to the following address in your favourite web browser.

Ensure that you replace “`<IPADDRESS>`” with your IP.

```
https://<IPADDRESS>:8443
```

### Initial Set Up of the UniFi Network Controller

**12.** When you first access your new Docker-based UniFi Network controller, you must complete some initial set up steps.

If you are setting up this controller as a brand new one, give it a server name, select your country, and accept the terms and conditions (**1.**).

After filling out your servers details, <kbd>click</kbd> the “`Next`” button (**3.**) to continue.

However, if you are restoring this from an older UniFi backup, <kbd>click</kbd> the “`Restore Server from a Backup`” link (**2.**)

<figure class="wp-block-image aligncenter size-full" id="bkmrk-">![Name your Docker UniFi Network Controller or Restore from Backup](https://pimylifeup.com/wp-content/uploads/2024/01/UniFi-Network-Controller-Docker-Container-01-Name-your-UniFI-Network-controller.jpg)</figure>**13.** If you are setting this controller up from scratch, you will now be asked to sign in to your Ubiquiti account (1.).

After filling out an email and password you can <kbd>click</kbd> the “`Create a UI Account`” button to create a new account, or you can <kbd>click</kbd> the “`Sign In`” button (**3.**) if you already have an account.

If you prefer not to use a Ubiquiti account on your controller, <kbd>click</kbd> the “`Advanced Setup`” link and follow the prompts (**2.**).

<figure class="wp-block-image aligncenter size-full" id="bkmrk--1">![Sign in to UI Account](https://pimylifeup.com/wp-content/uploads/2024/01/UniFi-Network-Controller-Docker-Container-02-Sign-in-to-UI-Account-or-Create-Local.jpg)</figure>**14.** At this point, you should now have access to the UniFi network controller web interface.

However, before you can start adopting your Ubiquiti network devices, there is an option you must enable.

<figure class="wp-block-image aligncenter size-full" id="bkmrk--2">![UniFi Network Controller Running in Docker Container](https://pimylifeup.com/wp-content/uploads/2024/01/UniFi-Network-Controller-Docker-Container-03-Network-Controller-Running.jpg)</figure>### Enabling the Inform Host Option

**15.** For your Ubiquiti devices to detect your Docker-based UniFi network controller, we must enable the “`Inform Host`” option.

This option lets us tell the IP address the controller should broadcast to available devices. Currently, it will be using the Dockers internal IP rather than the host IP.

To set this option, you must first switch to the settings page by <kbd>clicking</kbd> the cog in the sidebar.

<figure class="wp-block-image aligncenter size-full" id="bkmrk--3">![Open Settings page](https://pimylifeup.com/wp-content/uploads/2024/01/UniFi-Network-Controller-Docker-Container-04-Open-Settings-Page.jpg)</figure>**16.** Once you are on the settings screen, change to the “`System`” menu (**1.**).

After changing to the system settings page, swap to the “`Advanced`” tab (**2.**).

<figure class="wp-block-image aligncenter size-full" id="bkmrk--4">![Change to Advanced Settings](https://pimylifeup.com/wp-content/uploads/2024/01/UniFi-Network-Controller-Docker-Container-05-Change-to-Advanced-Settings.jpg)</figure>**17.** On this page, you should find an option labeled “`Inform Host`“.

<kbd>Click</kbd> the checkbox to allow us to begin overriding the host IP.

<figure class="wp-block-image aligncenter size-full" id="bkmrk--5">![Toggle on Inform Host](https://pimylifeup.com/wp-content/uploads/2024/01/UniFi-Network-Controller-Docker-Container-06-Enable-Inform-Host-Option.jpg)</figure>**18.** Before you can override the inform host value, you will get a warning that misconfiguring this option can cause you to lose access to your devices. You may have to physically reset your Ubiquiti devices if something goes wrong.

You need to ensure that the IP address of your host is correct and reachable. If you are happy to proceed, <kbd>click</kbd> the “`Confirm`” button.

<figure class="wp-block-image aligncenter size-full" id="bkmrk--6">![Confirm you want to Inform Host](https://pimylifeup.com/wp-content/uploads/2024/01/UniFi-Network-Controller-Docker-Container-07-Confirm-Override-Inform-Host.jpg)</figure>**19.** A text box will now appear below the “`Inform Host`” option. Type in the local IP address (**1.**) of the machine on which you are running the UniFi network controller using Docker.

Once you are happy that you have typed in the correct IP address, <kbd>click</kbd> the “`Apply Changes`” button (**2.**).

<figure class="wp-block-image aligncenter size-full" id="bkmrk--7">![Type in HOST IP For UniFi Docker Container Machine](https://pimylifeup.com/wp-content/uploads/2024/01/UniFi-Network-Controller-Docker-Container-08-Add-New-IP-for-Inform-Host.jpg)</figure>**20.** Once you have applied your settings, you must restart the UniFi Docker container.

Back in the terminal, you can bring the UniFi container down by using the following command

```
```bash
docker compose down
```<a class="copy-code-block fa-copy" href="https://pimylifeup.com/unifi-docker/#copy">Copy</a>
```

**21.** Start UniFi back up on your device by running the following command within the terminal.

```
```bash
docker compose up -d
```<a class="copy-code-block fa-copy" href="https://pimylifeup.com/unifi-docker/#copy">Copy</a>
```

## Updating your UniFi Docker Container

One massive advantage of using the UniFi network controller through a Docker container is that updating it is straightforward.

The following steps will walk you through the effortless way of updating to the latest version. You can see what versions are available by [visiting the GitHub page for this project](https://github.com/jacobalberty/unifi-docker/releases).

**1.** To update the UniFI container, we must change to the directory we created earlier in this guide.

We need to use the Compose file we wrote to pull the latest version of the image.

```
```bash
cd /opt/stacks/unifi
```<a class="copy-code-block fa-copy" href="https://pimylifeup.com/unifi-docker/#copy">Copy</a>
```

**2.** After swapping to the directory where we wrote the Compose file, you can use the command below to download the latest version of the UniFi container.

```
```bash
docker compose pull
```<a class="copy-code-block fa-copy" href="https://pimylifeup.com/unifi-docker/#copy">Copy</a>
```

**3.** Finally, if a new version is found, you can get Docker to move over to it using the command below in the terminal.

Docker will detect the new image and restart the container using it.

```bash
docker compose up -d
```