Connecting Docker Sqlite container to Java

  docker, java, sqlite

I just can’t find the correct information on the web.

I plan to run sqlite with Docker so that the information can be persisted to a local volume. My Dockerfile is

FROM alpine:3.14
RUN apk add --update sqlite
RUN mkdir /db
WORKDIR /db
ENTRYPOINT ["sqlite3"]
CMD ["mydb.db"]

docker run -p 5000:5000 -v ./data:/db my-sqlite mydb.db

I assume the information will be persisted to the folder ‘data’ in the current directory? Now I need the connection string – to connect from a Java project. What will this be ? I want to load up data from this db on starting the program, how would this be done?

Source: Docker Questions

LEAVE A COMMENT