skip to Main Content

I am currently using a laravel project with docker, I don’t understand but when I start docker using

docker-compose up -d

All is working good and very weel my container started and I can use it with my postgres database.

Also when I run
docker-compose down

and after I restart my container with

docker-compose up -d

all my migration and data was erased from my database

here is my docker-compose config

version: "3.7"
services:
  app:
    build:
      args:
        user: muze
        uid: 1000
      context: ./
      dockerfile: Dockerfile
    image: dockerizedapp
    container_name: docker-app
    restart: always
    depends_on:
        - db
    working_dir: /var/www/
    volumes:
      - ./:/var/www

  db:
    image: postgres:11-alpine
    container_name: docker-db
    restart: always
    ports:
        - "5432:5432"
    environment:
        POSTGRES_PASSWORD: ${DB_PASSWORD}
        POSTGRES_USER: ${DB_USERNAME}
        POSTGRES_DB: ${DB_DATABASE}
    volumes:
        - ./storage/app/postgresql/data:/var/lib/postgresql/data

  nginx:
    image: nginx:alpine
    container_name: docker-nginx
    restart: unless-stopped
    depends_on:
      - app
    ports:
      - 8000:80
    volumes:
      - ./:/var/www
      - ./docker-compose/nginx:/etc/nginx/conf.d/

thanks for your help

I try to mount a volume directly on docker I also see it but when I restart it is always empty

I already seen a lot of problem on stack overflow also nothing seem to be working ..

I use the latest version of docker

2

Answers


  1. Chosen as BEST ANSWER

    Resolved because on my env variable for postgres database I had PGDATA which is not specially needed for docker-compose

    Thanks for your help


  2. docker-compose down stops containers, deletes them and their networks. Try docker-compose stop.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search