title: pydantic error during dockerfile execution
body: <p>I have a fastapi project which is running correctly with docker-compose and the normal run. However, when I try to execute the project with only the dockerfile an error occurs.
  I HAVE TO read some config from .env and the variables are not updated with dockerfile.</p>
  <p>The command fails</p>
  <pre><code> docker run -p 8000:8000 --env-file ./.env test
  
      INFO:     Will watch for changes in these directories: ['/app']
  INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
  INFO:     Started reloader process [1] using statreload
  Process SpawnProcess-1:
  Traceback (most recent call last):
    File &quot;/usr/local/lib/python3.9/multiprocessing/process.py&quot;, line 315, in _bootstrap
      self.run()
    File &quot;/usr/local/lib/python3.9/multiprocessing/process.py&quot;, line 108, in run
      self._target(*self._args, **self._kwargs)
    File &quot;/usr/local/lib/python3.9/site-packages/uvicorn/subprocess.py&quot;, line 76, in subprocess_started
      target(sockets=sockets)
    File &quot;/usr/local/lib/python3.9/site-packages/uvicorn/server.py&quot;, line 68, in run
      return asyncio.run(self.serve(sockets=sockets))
    File &quot;/usr/local/lib/python3.9/asyncio/runners.py&quot;, line 44, in run
      return loop.run_until_complete(main)
    File &quot;/usr/local/lib/python3.9/asyncio/base_events.py&quot;, line 642, in run_until_complete
      return future.result()
    File &quot;/usr/local/lib/python3.9/site-packages/uvicorn/server.py&quot;, line 76, in serve
      config.load()
    File &quot;/usr/local/lib/python3.9/site-packages/uvicorn/config.py&quot;, line 456, in load
      self.loaded_app = import_from_string(self.app)
    File &quot;/usr/local/lib/python3.9/site-packages/uvicorn/importer.py&quot;, line 21, in import_from_string
      module = importlib.import_module(module_str)
    File &quot;/usr/local/lib/python3.9/importlib/__init__.py&quot;, line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1030, in _gcd_import
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1007, in _find_and_load
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 986, in _find_and_load_unlocked
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 680, in _load_unlocked
    File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 850, in exec_module
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 228, in _call_with_frames_removed
    File &quot;/app/./src/main.py&quot;, line 4, in &lt;module&gt;
      from src.api.wiki.api import api_router
    File &quot;/app/./src/api/wiki/api.py&quot;, line 1, in &lt;module&gt;
      from src.api.wiki.endpoints import document, category, document_topic
    File &quot;/app/./src/api/wiki/endpoints/document.py&quot;, line 3, in &lt;module&gt;
      from src.api.dependencies import get_db
    File &quot;/app/./src/api/dependencies.py&quot;, line 6, in &lt;module&gt;
      from src.core.config import settings
    File &quot;/app/./src/core/config.py&quot;, line 61, in &lt;module&gt;
      settings = get_settings()
    File &quot;/app/./src/core/config.py&quot;, line 58, in get_settings
      return Settings()
    File &quot;pydantic/env_settings.py&quot;, line 36, in pydantic.env_settings.BaseSettings.__init__
    File &quot;pydantic/main.py&quot;, line 406, in pydantic.main.BaseModel.__init__
  pydantic.error_wrappers.ValidationError: 15 validation errors for Settings
  API_STR
    field required (type=value_error.missing)
  PROJECT_NAME
    field required (type=value_error.missing)
  DESCRIPTION
    field required (type=value_error.missing)
  VERSION
    field required (type=value_error.missing)
  SWAGGER_UI_OAUTH2_REDIRECT_URL
    field required (type=value_error.missing)
  SECRET_KEY
    field required (type=value_error.missing)
  OPENAPI_CLIENT_ID
  APP_CLIENT_ID
    field required (type=value_error.missing)
  TENANT_ID
    field required (type=value_error.missing)
  INSTANCE
    field required (type=value_error.missing)
  DRIVER
    field required (type=value_error.missing)
  SERVER
    field required (type=value_error.missing)
  DATABASE
    field required (type=value_error.missing)
  USERNAME
    field required (type=value_error.missing)
  PASSWORD
    field required (type=value_error.missing)
  </code></pre>
  <p>Dockerfile</p>
  <pre><code>COPY src /app/src
  COPY ./requirements.txt /app/requirements.txt
  COPY ./.env /app/.env
  
  WORKDIR /app
  
  ENV PYTHONUNBUFFERED 1
  
  RUN pip3 install -r requirements.txt
  
  
  EXPOSE 8000
  
  CMD [&quot;uvicorn&quot;, &quot;src.main:app&quot;, &quot;--host=0.0.0.0&quot;, &quot;--reload&quot;, &quot;--port&quot;, &quot;8000&quot;]
  </code></pre>
  <p>I need some help to run the project.
  Thanks.</p>