# Docker

{% hint style="info" %}
Find [Docker Builds of SonarView here. ](https://hub.docker.com/r/nicknothom/sonarview/tags)
{% endhint %}

{% hint style="info" %}
BlueOS users should probably use the BlueOS Extension Store instead. These instructions describe how to run SonarView in a generic docker environment.&#x20;
{% endhint %}

## Step One: Install Docker (unless already installed)&#x20;

For Linux users looking for the simplest solution:&#x20;

```
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
```

Read the console output to determine if you need to adjust user or group permissions.&#x20;

For all other use cases, refer to the [Docker Installation Documentation ](https://docs.docker.com/engine/install/)

## Step Two: Install SonarView:

There are a few different ways to get up and running here. Review the options and choose what suits your needs best.

### **Docker Compose Method (simple)**

Configuration:

* You'll need to specify the directory that SonarView should save to in your host OS, which is mapped to `/userdata` in the container.  This is where log files will be saved, and this is where your SonarView config will live.`/usr/SonarView` is used for this example.&#x20;
* The container needs to run in the host network (`network_mode: host)` in order to be able to scan the network for available sonars. Device discovery can not work without host network mode.&#x20;
* `restart: unless-stopped` will automatically start the container on each boot.&#x20;
* Set `ENABLE_OS3D` to true if you have an Omniscan3D, else leave set to false.&#x20;
* `image: nicknothom/sonarview:latest`    will make it easier to grab new releases in the future without manually setting the version.&#x20;
  * If you'd rather use a specific version, replace with something like `nicknothom/sonarview:1.14.32-beta` . [Available tags can be found here](https://hub.docker.com/r/nicknothom/sonarview/tags).&#x20;
* If you need access to a serial device, you may need to add a device mapping like this:
  * ```
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0
    ```

Run the following in a terminal, replacing the default values with your preferences as needed:

```
# Create SonarView's docker compose file:
cat > docker-compose.yml << 'EOF'
services:
  sonarview:
    image: nicknothom/sonarview:latest
    container_name: sonarview
    network_mode: host
    restart: unless-stopped
    volumes:
      - /usr/SonarView:/userdata
    environment:
      - ENABLE_OS3D=false
    # Uncomment the lines below if you need to connect a USB serial device
    # devices:
    #   - /dev/ttyUSB0:/dev/ttyUSB0
    # group_add:
    #   - dialout
EOF

# Start the container
docker compose up -d
```

After the container starts, the SonarView Web UI should be available on port **7077** of your host.&#x20;

To update the container when a new SonarView version is released, run:

```
docker compose pull && docker compose up -d
```

### Docker Compose Method (with bundled FileBrowser)

This will spin up SonarView as well as a [FileBrowser](https://filebrowser.org/index.html) server that will make it easy to access log files. Configuration parameters are the same as above. Make sure that you have the same file path mapped for SonarView and FileBrowser as shown below.

```
# Create SonarView's docker compose file with FileBrowser:
cat > docker-compose.yml << EOF
services:
  sonarview:
    image: nicknothom/sonarview:latest
    container_name: sonarview
    network_mode: host
    restart: unless-stopped
    volumes:
      - /usr/SonarView:/userdata
    environment:
      - ENABLE_OS3D=false
    # Uncomment the lines below if you need to connect a USB serial device
    # devices:
    #   - /dev/ttyUSB0:/dev/ttyUSB0
    # group_add:
    #   - dialout

  filebrowser:
    image: filebrowser/filebrowser:latest
    container_name: filebrowser
    restart: unless-stopped
    ports:
      - "7080:80"
    volumes:
      - /usr/SonarView:/srv
      - ./filebrowser.db:/database.db
    environment:
      - PUID=1000
      - PGID=1000
EOF

# Start both containers
docker compose up -d

```

After the containers have started, you can fetch FileBrowser's temporary password with `docker logs filebrowser`. The default username is 'admin'.&#x20;

SonarView will be accessible on port 7077 via a web browser. FileBrowser will be accessible on port 7080 via a web browser.&#x20;

### **Without Docker compose (older install method):**&#x20;

Run the install command, replacing the default values with your preferences as needed:&#x20;

`sudo docker run -d -v /usr/SonarView:/userdata --pull=always --net=host --name=sonarview --restart=unless-stopped nicknothom/sonarview`

When using this method, the container will need to be updated manually by stopping the container, deleting it, and then recreating it from the new image:

```
docker kill sonarview
docker rm sonarview
sudo docker run -d -v /usr/SonarView:/userdata --pull=always --net=host --name=sonarview --restart=unless-stopped nicknothom/sonarview
```
