I have dockerized a existing django app and an existing postgres database.the tables are created in the docker container. But the tables are empty . There is no data in it.
if I connect to the docker container. And I do a \d+
                                                                         
|  Schema |                   Name                   |   Type   |     Owner     | Persistence |    Size    | Description  
| --------+------------------------------------------+----------+---------------+-------------+------------+------------- 
|  public | hotelWelzijnAdmin_animal                | table    | hotelwelzijn | permanent   | 8192 bytes |              
|  public | hotelWelzijnAdmin_animal_id_seq         | sequence | hotelwelzijn | permanent   | 8192 bytes |              
|  public | hotelWelzijnAdmin_category              | table    | hotelwelzijn | permanent   | 8192 bytes |            
|  public | hotelWelzijnAdmin_category_id_seq       | sequence | hotelwelzijn | permanent   | 8192 bytes |              
|  public | accounts_account                         | table    | hotelwelzijn | permanent   | 0 bytes    |             
|  public | accounts_account_groups                  | table    | hotelwelzijn | permanent   | 0 bytes    |              
|  public | accounts_account_groups_id_seq           | sequence | hotelwelzijn | permanent   | 8192 bytes |              
|  public | accounts_account_id_seq                  | sequence | hotelwelzijn | permanent   | 8192 bytes |              
|  public | accounts_account_user_permissions        | table    | hotelwelzijn | permanent   | 0 bytes    |              
|  public | accounts_account_user_permissions_id_seq | sequence | hotelwelzijn | permanent   | 8192 bytes |            
|  public | auth_group                               | table    | hotelwelzijn | permanent   | 0 bytes    |              
|  public | auth_group_id_seq                        | sequence | hotelwelzijn | permanent   | 8192 bytes |                
|  public | auth_group_permissions                   | table    | hotelwelzijn | permanent   | 0 bytes    |               
|  public | auth_group_permissions_id_seq            | sequence | hotelwelzijn | permanent   | 8192 bytes |              
|  public | auth_permission                          | table    | hotelwelzijn | permanent   | 8192 bytes |             
|  public | auth_permission_id_seq                   | sequence | hotelwelzijn | permanent   | 8192 bytes |          
Then the list of tables are shown. But the tables are empty.
Because if I do for example:
welzijn-# select * from accounts_account
no data is shown
This is the dockerfile:
# pull official base image
FROM python:3.9-alpine3.13
# set work directory
WORKDIR /usr/src/app
EXPOSE 8000
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install psycopg2 dependencies
RUN apk update \
    && apk add linux-headers postgresql-dev gcc python3-dev musl-dev
# install dependencies
RUN pip install --upgrade pip
COPY ./requirements.txt .
COPY ./requirements.dev.txt . 
RUN pip install -r requirements.txt
# copy entrypoint.sh
COPY ./entrypoint.sh .
RUN sed -i 's/\r$//g' /usr/src/app/entrypoint.sh
RUN chmod +x /usr/src/app/entrypoint.sh
# copy project
COPY . .
# run entrypoint.sh
ENTRYPOINT ["/usr/src/app/entrypoint.sh"]
and dockercompose file:
version: '3.9'
services:
  app:
   build:
     context: .
     args:
       - DEV=true
   ports:
      - "8000:8000"
   volumes:
      - .:/app
   command: >
      sh -c "python ./manage.py migrate &&      
             python ./manage.py runserver 0:8000"
   env_file:
      - ./.env
   depends_on:
      - db
  db:
    image: postgres:13-alpine
    container_name: postgres
    volumes:
      - dev-db-data:/var/lib/postgresql/data
    env_file:
      - ./.env
    ports:
      - '5432:5432'
      
volumes:
    dev-db-data:
    dev-static-data:
And this is the entrypoint.sh code:
#!/bin/sh
if [ "$DATABASE" = "postgres" ]
then
    echo "Waiting for postgres..."
    while ! nc -z $SQL_HOST $SQL_PORT; do
      sleep 0.1
    done
    echo "PostgreSQL started"
fi
python manage.py flush --no-input
python manage.py makemigrations --merge
python manage.py migrate --noinput
exec "$@"
Question: how to copy data from the host to the docker file?
dbcontainer. Here you can see commands: stackoverflow.com/questions/24718706/…