Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to drop `django_admin_log` with docker-compose?

I am using a docker-compose.yml file for my django app, and I am trying to do docker-compose run web python manage.py dbshell and drop the table django_admin_log like here.

But this returned
CommandError: You appear not to have the 'psql' program installed or on your path.

How can I do python manage.py dbshell or drop the table django_admin_log?

Here is my docker-compose.yml

storage:
  image: busybox
  volumes:
    - /var/lib/postgresql/data
    - /data
  command: true

db:
  image: postgres
  environment:
     - POSTGRESQL_DB=postgres
     - POSTGRESQL_USER=postgres
     - POSTGRESQL_PASSWORD=password
  volumes_from:
    - storage

web:
  build: .
  environment:
    - DATABASE_HOST=postgres
  command: ./run_web.sh
  ports:
    - "80:80"
  links:
    - db

Thank you

like image 414
ksmzn Avatar asked Dec 10 '25 10:12

ksmzn


1 Answers

Assuming you are using a Debian or Ubuntu-based image, in your Dockerfile, you just need to add the line:

RUN apt-get update && apt-get -y install postgresql

That will install the psql command for you and allow you to use the dbshell.

like image 114
Joey Wilhelm Avatar answered Dec 13 '25 04:12

Joey Wilhelm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!