> For the complete documentation index, see [llms.txt](https://wiki.codeandcompile.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.codeandcompile.com/product-reviews/smart-platforms/virtual-plcs/otee-open-architecture-real-time-virtual-plcs/otee-docker-commands.md).

# OTee Docker Commands

A handy reference for managing an OTee edge deployment (the vPLC agent + NATS) with Docker on a Linux edge device.

> **Note on names:** OTee's compose project and containers are named per device (e.g. `agent_<device>`, `nats-nats_<device>`, `agent-agent_<device>`). Run `docker ps -a` to see the exact names on your machine, and substitute them below.

## Check status

```bash
docker ps                       # running containers
docker ps -a                    # all containers, including stopped ones
docker images                   # installed images
docker volume ls                # volumes
docker logs <container> --tail 50          # last 50 log lines
docker logs <container> --tail 50 -f       # follow logs live
```

## Start, stop, restart

```bash
docker compose -p <project> up -d           # start the stack (detached)
docker compose -p <project> down            # stop + remove containers & network
docker compose -p <project> restart         # restart in place
```

**Tip:** `restart` reuses the existing container environment. If you've changed config or timezone, use `down` then `up -d` so the change is actually picked up.

## Run Docker without sudo

If Docker asks for `sudo`, your user isn't in the docker group yet:

```bash
sudo usermod -aG docker $USER
```

Then log out and back in (or reboot) for it to take effect.

## Full clean wipe (for a fresh install)

**Order matters**- remove containers *before* images. Stopped containers still hold image references, so `docker rmi` fails if you skip the container removal step.

```bash
# 1. Bring the stack down
docker compose -p <project> down

# 2. Force-remove any lingering containers
docker rm -f <nats-container> <agent-container>

# 3. Remove images (only works once the containers are gone)
docker rmi <agent-image> <nats-image>

# 4. Remove the volume (wipes runtime state)
docker volume rm <volume-name>
```

Verify it's clean:

```bash
docker ps -a && docker images && docker volume ls
```

## Install Docker (Debian-based devices)

```bash
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER      # then log out/in
```

## Troubleshooting a container that won't start

```bash
docker logs <container> --tail 50
```

Check the logs first, most start-up failures point to their cause there. If the container relies on time-sensitive services, make sure the device clock is synced (`timedatectl` / `chronyc tracking`) before retrying.
