personal=df.values.tolist()
conn=sqlite3.connect("data.db",detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
cursor=conn.cursor()
for item in personal:
cursor.execute('insert or replace into Final values (?,?,?,?,?,?,?,?,?)', item)
conn.commit()
There is no mention of sqlite in the dockerfile, what should I do to save changes in the data.db file?
FROM python:3.7
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ADD linkedin_scrape.py .
COPY requirements.txt ./requirements.txt
COPY final_links.csv ./final_links.csv
COPY textdata.txt ./textdata.txt
COPY credentials.txt ./credentials.txt
COPY data.db ./data.db
COPY vectorizer.pk ./vectorizer.pk
COPY model_IvE ./model_IvE
COPY model_JvP ./model_JvP
COPY model_NvS ./model_NvS
COPY model_TvF ./model_TvF
COPY nocopy.xlsx ./nocopy.xlsx
RUN pip install -r requirements.txt
RUN wget -q -O - https://dl-
ssl.google.com/linux/linux_signing_key.pub |
apt-key add -
RUN sh -c 'echo "deb [arch=amd64]
http://dl.google.com/linux/chrome/deb/
stable main" >> /etc/apt/sources.list.d/google-chrome.list'
RUN apt-get -y update
RUN apt-get install -y google-chrome-stable
# set display port to avoid crash
EXPOSE 8080
CMD python linkedin_scrape.py --bind 0.0.0.0:8080 --timeout 90
This is my dockerfile.Can you please guide me step by step, thanks.
You'll need to determine in which directory in the container the (Python) process is running.
Often you can discern this from the WORKDIR
directory used in the Dockerfile
.
Then -- assuming that data.db
is created in that directory -- you can use Docker's volume mounting to mount a host file into the container at the same location.
For example:
HOST=${PWD}
CONT=${WORKDIR}
docker run --volume=${HOST}/data.db:/${CONT}/data.db ... your-image
Where HOST
points to the directory on the host and CONT
points to the directory (probably the same directory as used by WORKDIR
) on the container.
NOTE If, after running the container, the host's (!)
data.db
is a directory rather than a file, then you've incorrectly determined the file's location in the container. By default, Docker volume mounts directories not files.
NOTE Another way to identify the container file's location is to
docker exec
into the running container and locate the file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.