Coder Social home page Coder Social logo

dockerfile_of_sqlite3's Introduction

Dockerfile of SQLite3

Alpine Docker image of SQLite3 built from the latest source code.

Image Information (Dockerfile, Security Scan, etc.)

Usage


Build the latest image locally as below:

```shellsession
$ docker build -t sqlite3:local https://github.com/iomax/Dockerfile_of_SQLite3.git
...

Interactive

Running sqlite3 command inside the container interactively.

$ docker run --rm -it -v "$(pwd):/workspace" -w /workspace sqlite3:local
SQLite version 3.28.0 2019-04-16 19:49:53
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open ./sample.db
sqlite> CREATE TABLE table_sample(timestamp TEXT, description TEXT);
sqlite> INSERT INTO table_sample VALUES(datetime("now"),"First sample data. Foo");
sqlite> INSERT INTO table_sample VALUES(datetime("now"),"Second sample data. Bar");
sqlite> .quit
$ ls
sample.db
  • Note that you need to mount the working directory as a volume to the container.

Command

  • Running sqlite3 --version command:
$ docker run --rm sqlite3:local sqlite3 --version
3.38.2 2022-03-26 13:51:10 d33c709cc0af66bc5b6dc6216eba9f1f0b40960b9ae83694c986fbf4c1d6f08f
  • Executing SQL query to the mounted database:
$ ls
sample.db
$ docker run --rm -it -v "$(pwd):/workspace" sqlite3:local sqlite3 /workspace/sample.db -header -column 'SELECT rowid, * FROM table_sample;'
rowid  timestamp            description
-----  -------------------  -----------------------
1      2022-04-16 14:09:52  First sample data. Foo
2      2022-04-16 14:09:58  Second sample data. Bar
  • Note that you need to mount the working directory as a volume to the container.

Run test

This container includes a simple test script.

You can run the script to see if the container and sqlite3 binary is working.

$ docker run --rm sqlite3:local /run-test.sh
- Creating test DB ... created
rowid  timestamp            description
-----  -------------------  -----------------------
1      2022-04-16 14:18:34  First sample data. Hoo
2      2022-04-16 14:18:34  Second sample data. Bar
- Testing ...
  1st row value ... OK
  2nd row value ... OK

- Test result:
success
$ echo $?
0

License

dockerfile_of_sqlite3's People

Contributors

iomax avatar keinos avatar mergify[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.