Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

once i docker-compose down i lose all my settings #52

Open
TheSearcher opened this issue Jul 16, 2019 · 8 comments
Open

once i docker-compose down i lose all my settings #52

TheSearcher opened this issue Jul 16, 2019 · 8 comments

Comments

@TheSearcher
Copy link

i was able to spin a magento2 version with docker-compose up -

however, once i docker-compose down i lose everything.

is this how its set up to be or did i do something wrong.

thank you

@tomhrtly
Copy link

Try docker-compose stop instead.

@krskibin
Copy link

Is there any other solution for this? Maybe adding extra volume for Magento host data will solve the problem.

@osmansafak
Copy link

You must add volumes to the web service.

Edit the docker-compose.yml file as follows.

version: "3.0"
services:
  web:
    image: alexcheng/magento2
    ports:
      - "80:80"
    links:
      - db
    volumes:
      - web-file:/var/www
    env_file:
      - env
  db:
    image: mysql:5.7
    volumes:
      - db-data:/var/lib/mysql
    env_file:
      - env
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    ports:
      - "8580:80"
    links:
      - db
volumes:
  db-data:
  web-file:

@krskibin
Copy link

Unfortunetly, @osmansafak doesn't work. With your docker-compose config I can't even import data running install-sampledata command. It shows me some erros with authentication and so on 😞.

@Gorynych
Copy link

Gorynych commented Dec 8, 2019

I got the same problem.

And it's very strange. Using volumes actually intends to not have it, but... ((

@TheSearcher
Copy link
Author

@osmansafak hi. can you raise this question/issue on https://magento.stackexchange.com/ and i will show you how to fix the error

@philologos
Copy link

philologos commented Feb 17, 2020

I had a similar problem.

After running docker-compose up -d and docker exec -it <container-id> install-magento everything worked fine. As soon as I ran docker-compose down and started to re-run the containers, a database error occured (could not find table). I did solve it by adapting the db volume destination from db-data:/var/lib/mysql/data to db-data:/var/lib/mysql and adding external: true to both named volumes. Therefore I had to create them before running docker-compose up -d with the commands docker volume create --name=magento-data and docker volume create --name=db-data. I am using external: true mainly since I had some issues in the past whilst referencing named volumes when project names changed, it might be not critical to solve the issue above. For the sake of completeness, you find my docker-compose.yml below:

version: '3'
services:
  web:
    image: alexcheng/magento2
    ports:
      - "80:80"
    links:
      - db
    volumes: 
      - magento-data:/var/www/html  
    env_file:
      - env
  db:
    image: mysql:5.6.23
    volumes:
      - db-data:/var/lib/mysql
    env_file:
      - env
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    ports:
      - "8580:80"
    links:
      - db     
volumes:
  magento-data:
    external: true
  db-data:
    external: true

Maybe this helps anybody. If this is a common problem it might worth a pull request.

@mverleg
Copy link

mverleg commented May 19, 2020

If you want to control where the data goes, an alternative is (at the end of docker-compose.yml):

volumes:
  magento-data:
  db-data: 
    driver: local
    driver_opts:
      type: 'none'
      o: 'bind'
      device: '/data/magento/db'

This is in addition to db-data:/var/lib/mysql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants