Embed sqlite database to docker container?

2019-03-12 21:00发布

I'm new to Docker. Is it possible to embed a sqlite database in a docker container and have it updated every time my script in that container runs?

标签: docker
2条回答
不美不萌又怎样
2楼-- · 2019-03-12 21:50

Dockerfile example to install sqlite3

FROM ubuntu:trusty
RUN sudo apt-get -y update
RUN sudo apt-get -y upgrade
RUN sudo apt-get install -y sqlite3 libsqlite3-dev
RUN mkdir /db
RUN /usr/bin/sqlite3 /db/test.db
CMD /bin/bash

persist the db file inside host OS folder /home/dbfolder

docker run -it -v /home/dbfolder/:/db imagename
查看更多
一纸荒年 Trace。
3楼-- · 2019-03-12 21:53

If you want to persist the data in sqlite, use host directory/file as a data volume Refer "Mount a host directory as a data volume" section in https://docs.docker.com/engine/admin/volumes/volumes/

查看更多
登录 后发表回答