Open TheSearcher opened 5 years ago
Try docker-compose stop
instead.
Is there any other solution for this? Maybe adding extra volume for Magento host data will solve the problem.
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:
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 :disappointed:.
I got the same problem.
And it's very strange. Using volumes actually intends to not have it, but... ((
@osmansafak hi. can you raise this question/issue on https://magento.stackexchange.com/ and i will show you how to fix the error
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.
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
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