Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

starting/stopping docker-compose services inside backup service #173

Open
johnhelt opened this issue Sep 7, 2023 · 1 comment
Open

starting/stopping docker-compose services inside backup service #173

johnhelt opened this issue Sep 7, 2023 · 1 comment
Labels

Comments

@johnhelt
Copy link

johnhelt commented Sep 7, 2023

I'm trying to wrap my head around if what I'm trying is actually not possible:
I have a bunch of services I want stopped. The services are defined by docker-compose files and contain binds to volumes on the local file system (outside docker).

Using the PRE_COMMANDS env variable, I can shut down the services just fine inside the backup container, after I installed docker-compose by patching the Dockerfile. The problem I have is that I cannot start them again, because all mounts point to locations on the local fs, which dont exist in docker container. Even if I could somehow solve this, I'm afraid that running docker-in-docker would lead to unexpected results if the backup container gets stopped. I don't see any good way around this rather than running my start script outside the docker container, and then, why bother using docker at all, unless it is to avoid installing restic locally?

@smainz
Copy link
Contributor

smainz commented Sep 12, 2023

Why do you need to shut them down? It should be enough to stop and start the containers. I do it like this:

  restic-backup:
    image: mazzolino/restic:1.7
    container_name: restic-backup
    restart: always
    environment:
      PRE_COMMANDS: |-
        docker stop nexus-app
      POST_COMMANDS_EXIT: |-
        docker start nexus-app
    ...

You only have to give the correct name for the container:

services:
  nexus:
    image: sonatype/nexus3:3.53.1
    container_name: nexus-app
    restart: always
   ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants