1 year ago

#239316

test-img

Aw3same

Best approach to upload volume to repository

I'm developing an API rest using Python and Flask in a Docker image. In developing using the feature Remote-Containers from VS Code (in windows, with Docker Desktop installed).

This API uses a volume created locally in my pc. I connect the volume when the VSCode open the container. My .devcontainer.json

{
    "name": "Existing Dockerfile",
    "context": "..",  
    "dockerFile": "../dockerfile",
    "settings": {
      "git.path": "/usr/bin/git"
    },
    "extensions": [
      "mhutchie.git-graph",
      "eamodio.gitlens",
  
      "tht13.python",
      "esbenp.prettier-vscode",
      "ms-azuretools.vscode-docker"
    ],
    "runArgs": ["-v", "persisted-dictionaries:/dictionaries/data"]
}

My dockerfile (just in case)

FROM python

WORKDIR /app
COPY . /app
RUN pip --no-cache-dir install -r requirements.txt

ENV FLASK_APP=app.py
ENV FLASK_ENV=development

EXPOSE 5001:5000

CMD ["flask", "run", "-h" , "0.0.0.0"]

I'm newbie to this kind of working an development, and the official documentation can be a bit overwhelming, so I have a few questions:

  • I want to upload this to a repository, but I don't known how to upload the volume. Is there a way to create, if not exists, the volume? This is thinking in new people developing and don't have a volume created (until we have a remote volume). What I want is, with a simple git clone, be able to have the full develop environment, if is possible.
  • Am I using the 'best' way to connect my volume to my devcontainer? Reading a lot of questions, this one is the one that works for me, but i don't know the implications.
  • Taking advantage of this question, is there a better way to do this? I have followed a lot of tutorials, and my project is a mix of some tutorials.
  • Should I change from Dockerfile to Docker-compose ? It seems that with docker-compose is 'easier'.

Sorry if the questions are a bit odd, but i'm new to all of this and i don't know if i'm on the right path. Thanks in advance!

python

docker

vscode-devcontainer

0 Answers

Your Answer

Accepted video resources