0

Docker does not save to volumes.

I have tried different combinations, but it just doesn't save to the volumes. None of them save to the volumes...

I run them with the commands:

$ sudo docker-compose up -d --remove-orphans
$ sudo docker-compose start

If i stop and start the docker containers, then the data is there again (that means that docker saves the data somewhere.. just not in the volumes I specified)

My Host machine is running ubuntu 20.04

What to do?

// docker-compose.yml

version: "3.7"
services:
  sqlserver:
    image: mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04
    ports:  
      - "1433:1433"
      - "5022:5022"
    volumes:
        - /media/m/DataLinux/Code/Docker/db-playground/sqldata:/var/opt/sqlserver/data
        # - /media/m/DataLinux/Code/Docker/db-playground/sqlbackup:/var/opt/mssql/backups
        # - /media/m/DataLinux/Code/Docker/db-playground/sqlserver:/var/opt/sqlserver
        # - /media/m/DataLinux/Code/Docker/db-playground/mssql:/var/opt/mssql
    environment:
      USERID: sa
      SA_PASSWORD: Dev1234!
      ACCEPT_EULA: Y
  mongo:
    image: amd64/mongo:4.4.3-bionic
    restart: always
    volumes:
      - /media/m/DataLinux/Code/Docker/db-playground/mongo-data:/var/data
    ports:  
        - "27017:27017"
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: secret
  postgres:
    image: supabase/postgres:0.14.0
    ports:
      - "5432:5432"
    environment:
      POSTGRES_PASSWORD: postgres # user: postgres


# volumes:
#   sqldata:
#   mongo-data:
#   sqlsystem:
  # sqllog:
  # sqlbackup:
  # sqlsecrets:

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Martin Andersen
  • 173
  • 1
  • 8
  • I guess you are not looking in the right place. This might help: https://stackoverflow.com/questions/36014554/how-to-change-the-default-location-for-docker-create-volume-command – Ralf Jan 19 '21 at 09:38

2 Answers2

0

Your question is so confusing :))

Based on your docker, you specify absolute path to as volume to store data. Eg:

media/m/DataLinux/Code/Docker/db-playground/sqldata

Then if you're containers are started successfully you should go and check in that location. (otherwise if any issue happens during bootstraping it'll display immediately and you can see what's going on)

I also see you define volumes in the end of your docker-compose.yml. Note that if you use that kind of volume, those are Docker volumes - volumes managed by Docker. They are stored in /var/lib/docker/volumes, you should not ever manually touching them, instead you should work with them using Docker cli:

docker volume create <volume name>
docker volume delete <volume name>
...
Duc Trung Mai
  • 2,141
  • 1
  • 24
  • 23
0

Solution for SQL-SERVER:

SOLUTION:

Adding the user: root part works for me.

Running ubuntu on host.

This is my file:

docker-compose.yml

version: "3.7"
services:
  sqlserver:
    image: mcr.microsoft.com/mssql/server:2019-latest
    container_name: sqlserver
    user: root   #####################   <<<<<<<<< IMPORTANT!!!!!  ############
    ports:
    #   host-port:container-port 
      - "1433:1433"
    environment:
      # SA_USERNAME: sa
      SA_PASSWORD: Dev1234!
      ACCEPT_EULA: Y
    volumes:
      - ./volumes/data2:/var/opt/mssql/data
Martin Andersen
  • 173
  • 1
  • 8