Home:ALL Converter>Docker swarm doesnt save volumes

Docker swarm doesnt save volumes

Ask Time:2020-11-13T18:07:28         Author:Hollie Molen

Json Formatter

I have the following docker-compose

   version: "3.7"
   sonarqube:
        image: sonarqube:8.2-community
        depends_on:
          - db
        ports:
          - '9000:9000'
        environment:
          SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
          SONAR_JDBC_USERNAME: sonar
          SONAR_JDBC_PASSWORD: sonar
          SONAR_WEB_PORT: 9000
          SONAR_EXCLUSIONS: java
        volumes:
          - sonarqube_data:/opt/sonarqube/data
          - sonarqube_extensions:/opt/sonarqube/extensions
          - sonarqube_logs:/opt/sonarqube/logs
          - sonarqube_temp:/opt/sonarqube/temp
    db:
        image: postgres
        environment:
          POSTGRES_USER: sonar
          POSTGRES_PASSWORD: sonar
        volumes:
          - postgresql:/var/lib/postgresql
          # This needs explicit mapping due to https://github.com/docker-library/postgres/blob/4e48e3228a30763913ece952c611e5e9b95c8759/Dockerfile.template#L52
          - postgresql_data:/var/lib/postgresql/data
    volumes:
      sonarqube_data:
      sonarqube_extensions:
      sonarqube_logs:
      sonarqube_temp:
      postgresql:
      postgresql_data:

When i do the following command: docker-compose up and then make a project in sonarqube, and then proceed to do docker-compose down, and then docker-compose up again. it all saves.

However when i try to create a swarm with the following commands it does not save.

docker swarm init

docker stack deploy -c docker-compose.yml test-stack

and then put it all down: docker swarm leave -f

How to fix this problem?

Author:Hollie Molen,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/64818991/docker-swarm-doesnt-save-volumes
yy