jaswdr / docker-image-sybase

SQL Anywhere Database Docker Image
16 stars 14 forks source link

Different database on startup #5

Closed Barfknecht closed 4 years ago

Barfknecht commented 4 years ago

I am using the following docker-compose script to start up the container:

version: "3.8"

services:
  db:
    image: jaschweder/sybase
    ports:
        - "2638:2638"
        - "49152:49152"
    volumes:
      - type: bind
        source: .
        target: /opt/database
        volume:
          nocopy: true
volumes:
  mydata:

I have a database file on my local machine that I am mapping to the target in the container, and all is working fine. The only issue I am experiencing is that the original image always starts up demo.db.

How am I able to stop this from happening without having to recreate your image?

jaswdr commented 4 years ago

hello @Barfknecht, this happens because of this line https://github.com/jaswdr/docker-image-sybase/blob/master/Dockerfile#L9, this is done to enable a quick start using the default sa that you can see in README.

To fix your problem you can create a new Dockerfile, like this one:

FROM jaschweder/sybase

CMD ["dbsrv16", "/path/to/your/database.db"]

then you can make this changes to your docker-compose.yaml

version: "3.8"

services:
  db:
    build: .
...

since this is only rewriting the CMD section, this will use the original image as cache and you are done.

Other option is to map your local database file to the demo.db, like:

version: "3.8"

services:
  db:
    image: jaschweder/sybase
    ports:
        - "2638:2638"
        - "49152:49152"
    volumes:
      - type: bind
        source: .
        target: /opt/database
        volume:
          nocopy: true
      - ./mydatabase.db:/opt/sqlanywhere16/demo.db
volumes:
  mydata:
Barfknecht commented 4 years ago

Thank you so much! Worked like a charm