Repository: nautobot/nautobot

Issue:
serve-docs Doesn't Stop on Invoke stop
<!--
    NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED.

    This form is only for reporting reproducible bugs. If you need assistance
    with Nautobot installation, or if you have a general question, please start a
    discussion instead: https://github.com/nautobot/nautobot/discussions

    Please describe the environment in which you are running Nautobot. Be sure
    that you are running an unmodified instance of the latest stable release
    before submitting a bug report, and that any plugins have been disabled.
-->
### Environment
* Nautobot version (Docker tag too if applicable): Latest
* Python version: N/A
* Database platform, version: n/a
* Middleware(s): n/a

<!--
    Describe in detail the exact steps that someone else can take to reproduce
    this bug using the current stable release of Nautobot. Begin with the
    creation of any necessary database objects and call out every operation
    being performed explicitly. If reporting a bug in the REST API, be sure to
    reconstruct the raw HTTP request(s) being made: Don't rely on a client
    library such as pynautobot.
-->
### Steps to Reproduce
1. `poetry install`
2. `invoke --list` to get the available commands
3. `invoke serve-docs`
4. `invoke stop`


<!-- What did you expect to happen? -->
### Expected Behavior

Expected the docs container to stop running


<!-- What happened instead? -->
### Observed Behavior

Container keeps on serving those docs.


Discussion:
I don't see that behavior in `develop`:

```
❯ invoke serve-docs
Starting Nautobot in detached mode...
Running docker compose command "up --detach"
PYTHON_VER=3.12 \
docker compose \
    --project-name "nautobot" \
    --project-directory "/Users/glennmatthews/Documents/git-stuff/nautobot/development/" \
    -f "/Users/glennmatthews/Documents/git-stuff/nautobot/development/docker-compose.yml" \
    -f "/Users/glennmatthews/Documents/git-stuff/nautobot/development/docker-compose.postgres.yml" \
    -f "/Users/glennmatthews/Documents/git-stuff/nautobot/development/docker-compose.dev.yml" up \
    --detach mkdocs
Container nautobot-mkdocs-1  Creating
Container nautobot-mkdocs-1  Created
Container nautobot-mkdocs-1  Starting
Container nautobot-mkdocs-1  Started

❯ invoke stop      
Stopping Nautobot...
Running docker compose command "down"
PYTHON_VER=3.12 \
docker compose \
    --project-name "nautobot" \
    --project-directory "/Users/glennmatthews/Documents/git-stuff/nautobot/development/" \
    -f "/Users/glennmatthews/Documents/git-stuff/nautobot/development/docker-compose.yml" \
    -f "/Users/glennmatthews/Documents/git-stuff/nautobot/development/docker-compose.postgres.yml" \
    -f "/Users/glennmatthews/Documents/git-stuff/nautobot/development/docker-compose.dev.yml" down
Container nautobot-celery_beat-1  Stopping
Container nautobot-mkdocs-1  Stopping
Container nautobot-celery_worker-1  Stopping
Container nautobot-celery_beat-1  Stopping
Container nautobot-mkdocs-1  Stopping
Container nautobot-celery_worker-1  Stopping
Container nautobot-celery_beat-1  Stopped
Container nautobot-celery_beat-1  Removing
Container nautobot-celery_beat-1  Removed
Container nautobot-celery_worker-1  Stopped
Container nautobot-celery_worker-1  Removing
Container nautobot-celery_worker-1  Removed
Container nautobot-nautobot-1  Stopping
Container nautobot-nautobot-1  Stopping
Container nautobot-nautobot-1  Stopped
Container nautobot-nautobot-1  Removing
Container nautobot-nautobot-1  Removed
Container nautobot-redis-1  Stopping
Container nautobot-redis-1  Stopping
Container nautobot-db-1  Stopping
Container nautobot-db-1  Stopping
Container nautobot-selenium-1  Stopping
Container nautobot-selenium-1  Stopping
Container nautobot-db-1  Stopped
Container nautobot-db-1  Removing
Container nautobot-db-1  Removed
Container nautobot-redis-1  Stopped
Container nautobot-redis-1  Removing
Container nautobot-redis-1  Removed
Container nautobot-selenium-1  Stopped
Container nautobot-selenium-1  Removing
Container nautobot-selenium-1  Removed
Container nautobot-mkdocs-1  Stopped
Container nautobot-mkdocs-1  Removing
Container nautobot-mkdocs-1  Removed
Network nautobot_default  Removing
Network nautobot_default  Removed

❯ docker ps                               
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

❯ docker compose version    
Docker Compose version v2.13.0

❯
```

Can you confirm your docker compose version?
Version is 2.26.1

```
❯ docker compose version
Docker Compose version v2.26.1
```

I'm getting the following:
```
❯ inv stop
Stopping Nautobot...
Running docker compose command "down"
PYTHON_VER=3.8 \
docker compose \
    --project-name "nautobot" \
    --project-directory "/home/joshv/projects/nautobot/development/" \
    -f "/home/joshv/projects/nautobot/development/docker-compose.yml" \
    -f "/home/joshv/projects/nautobot/development/docker-compose.postgres.yml" \
    -f "/home/joshv/projects/nautobot/development/docker-compose.dev.yml" down
time="2024-04-26T11:45:45-05:00" level=warning msg="/home/joshv/projects/nautobot/development/docker-compose.yml: `version` is obsolete"
time="2024-04-26T11:45:45-05:00" level=warning msg="/home/joshv/projects/nautobot/development/docker-compose.postgres.yml: `version` is obsolete"
time="2024-04-26T11:45:45-05:00" level=warning msg="/home/joshv/projects/nautobot/development/docker-compose.dev.yml: `version` is obsolete"
 Network nautobot_default  Removing
 Network nautobot_default  Resource is still in use
```

Checking the interwebs about it.
I was able to replicate it:

```bash
root@ntc ~/nautobot develop nautobot-bzAc2NSp-py3.8 ❯ inv serve-docs
Starting Nautobot in detached mode...
Running docker compose command "up --detach"
PYTHON_VER=3.8 \
docker compose \
    --project-name "nautobot" \
    --project-directory "/root/nautobot/development/" \
    -f "/root/nautobot/development/docker-compose.yml" \
    -f "/root/nautobot/development/docker-compose.postgres.yml" \
    -f "/root/nautobot/development/docker-compose.dev.yml" up \
    --detach mkdocs
time="2024-04-26T11:55:34-05:00" level=warning msg="/root/nautobot/development/docker-compose.yml: `version` is obsolete"
time="2024-04-26T11:55:34-05:00" level=warning msg="/root/nautobot/development/docker-compose.postgres.yml: `version` is obsolete"
time="2024-04-26T11:55:34-05:00" level=warning msg="/root/nautobot/development/docker-compose.dev.yml: `version` is obsolete"
 Network nautobot_default  Creating
 Network nautobot_default  Created
 Container nautobot-mkdocs-1  Creating
 Container nautobot-mkdocs-1  Created
 Container nautobot-mkdocs-1  Starting
 Container nautobot-mkdocs-1  Started
root@ntc ~/nautobot develop nautobot-bzAc2NSp-py3.8 ❯ docker ps
CONTAINER ID   IMAGE                            COMMAND                  CREATED         STATUS         PORTS                                                 NAMES
534fb0e824e2   local/nautobot-dev:local-py3.8   "mkdocs serve -a 0.0…"   4 seconds ago   Up 4 seconds   0.0.0.0:8001->8001/tcp, :::8001->8001/tcp, 8080/tcp   nautobot-mkdocs-1
root@ntc ~/nautobot develop nautobot-bzAc2NSp-py3.8 ❯ inv stop
Stopping Nautobot...
Running docker compose command "down"
PYTHON_VER=3.8 \
docker compose \
    --project-name "nautobot" \
    --project-directory "/root/nautobot/development/" \
    -f "/root/nautobot/development/docker-compose.yml" \
    -f "/root/nautobot/development/docker-compose.postgres.yml" \
    -f "/root/nautobot/development/docker-compose.dev.yml" down
time="2024-04-26T11:55:41-05:00" level=warning msg="/root/nautobot/development/docker-compose.yml: `version` is obsolete"
time="2024-04-26T11:55:41-05:00" level=warning msg="/root/nautobot/development/docker-compose.postgres.yml: `version` is obsolete"
time="2024-04-26T11:55:41-05:00" level=warning msg="/root/nautobot/development/docker-compose.dev.yml: `version` is obsolete"
 Network nautobot_default  Removing
 Network nautobot_default  Resource is still in use
root@ntc ~/nautobot develop nautobot-bzAc2NSp-py3.8 ❯
```

Same docker compose version as Josh.
Thanks for the data. I can see that I need to update my local docker, but interesting that this has changed.
@smk4664 would love to also see what you have to think on this? Do you have the same behavior?
I do not have this issue, but I did need to do `invoke build` before I could do the `invoke serve-docs`.
Might just be as simple as changing the `stop` task definition to perform `docker compose down --profile '*'`? Haven't tried.
Needs to be `docker compose --profile '*' down` but that works for me both with docker 4.15 and after upgrading to 4.29.

Resolving patch:
diff --git a/tasks.py b/tasks.py
--- a/tasks.py
+++ b/tasks.py
@@ -408,7 +408,7 @@ def stop(context, service=None):
     """Stop Nautobot and its dependencies."""
     print("Stopping Nautobot...")
     if not service:
-        docker_compose(context, "down")
+        docker_compose(context, "--profile '*' down")
     else:
         docker_compose(context, "stop", service=service)
 


Test patch: