3

This dockerfile is working correctly. But how do I execute commands within dockerfile?

FROM alpine 
RUN apk add --update sqlite && rm -rf /var/cache/apk/*
RUN apk add --update wget && rm -rf /var/cache/apk/*
RUN wget --no-check-certificate https://cdn.rawgit.com/times/data/master/sunday_times_panama_data.zip
RUN unzip sunday_times_panama_data.zip

But the next part needs to be executed at sqlite prompt. How do I declare this part?

# sqlite commands:
sqlite3 sundayTimesPanamaPapers.sqlite
.mode csv
CREATE TABLE panama(company_url TEXT,company_name TEXT,officer_position_es TEXT,officer_position_en TEXT,officer_name TEXT,inc_date TEXT,dissolved_date TEXT,updated_date TEXT,company_type TEXT,mf_link TEXT);
.import sunday_times_panama_data.csv panama
1

2 Answers 2

1

I can save the commands to a file and then execute the file in a dockerfile like this...

ADD sqlite_commands.sql /
RUN sqlite3 panama.sqlite < /sqlite_commands.sql
Sign up to request clarification or add additional context in comments.

Comments

0

Just feed it the commands using a pipe:

RUN echo '.mode csv\nCREATE TABLE panama(company_url TEXT,company_name TEXT,officer_position_es TEXT,officer_position_en TEXT,officer_name TEXT,inc_date TEXT,dissolved_date TEXT,updated_date TEXT,company_type TEXT,mf_link TEXT);\n.import sunday_times_panama_data.csv panama' | sqlite3 sundayTimesPanamaPapers.sqlite

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.