0
Since sqlite3 banks are only files;
And containers, by their own logic of scalability are created and excluded according to need;
What is the best way to work with both partners?
You see, I’m trying to avoid creating a new image or volume for this bank, but honestly I’m open to possibilities.
I asked a related question here, but with another focus.
I also know that there may be a thousand alternatives to the bank chosen, but as new in the area, I have familiarity and confidence in sqlite3 and would like solutions to this.
----- Edited -----
I have in my app folder, a subfolder called volume.
And I’d like to access the folder /var/www/volumet host.
My Dockerfile after the answer:
FROM python:3-alpine
ADD ./var/www/volumet /app
WORKDIR /app
RUN apk add --update alpine-sdk make gcc python3-dev python-dev libxslt-dev libc-dev openssl-dev libffi-dev
RUN pip install --trusted-host pypi.python.org -r requirements.txt
EXPOSE 5050
ENV NAME Ibuprofenovar
CMD ["python", "app.py"]
My Docker-Compose.yml after reply:
version: "3"
services:
web:
build: .
volumes:
- /var/www/volumet:/volume
deploy:
replicas: 3
resources:
limits:
cpus: "0.1"
memory: 50M
restart_policy:
condition: on-failure
ports:
- "4000:5050"
Good morning, @Luiseduardo. According to your answer, I edited my question, but still unsuccessful
– Alexander
You built it after the Docker-Compose change?
– Luis Eduardo
Yes, but it hangs in the ADD command and does not finish the build. I tried to change the /var/www/volumet for ../../../../www/volumet but from the path Forbidden. Maybe I’m ignoring Docker’s idea of using directories from inside the image directory, but I think if I use it that way, when updating my files with a git pull for example, it overwrites my database likewise.
– Alexander
suggested changes, with the volume created, you do not need the Copy, and also need the . after the ADD as in my dockerfile ADD . /code /app
– Luis Eduardo
Yeah, but this way, with . it uses my project path, right? There’s no way to access the host’s /var/www path? Otherwise, if it is impossible, I will close my question right here, accept and give as answered.
– Alexander
If your dockerfile and Compose is in an X folder and your code is in a Y folder, you need to put ADD. /Y /app, because it is the local path + the folder path q you want to create the volume, in this case the folder Y, only the files inside it will be mirrored inside the container. Now if you want to put everything, just put ADD . /app so all local data will be mirrored inside.
– Luis Eduardo
I managed to insert the bank already created in the containers, but I can’t change it, as if the path of my volume was not right.
– Alexander
In my code, I go to the folder /volume and I can make changes to it, but these changes don’t affect my host folder, only the one in the container
– Alexander
Here friend, this solves your problem. https://github.com/LuisMSoares/sqlite-docker-compose
– Luis Eduardo
I know I’m not supposed to keep saying things like thank you or whatever. But something came up here that became a priority, so when the time comes for new tests, I make a new position. I will probably delete this comment in the sequence. Thanks for the response and interest.
– Alexander