eZ Platform Discussions

eZ Launchpad - ConnectionException after restart the container

version2

#1

Hi,

I have a problem with restarting my docker instance created with eZ Launchpad.

I create a blank installation

~/ez init

I can stop / start without problem.

~/ez docker:stop 
~/ez docker:start 

But if I want to start it completely.
To take into account changes in docker-compose.yml for example.

~/ez docker:down 
~/ez docker:up 
~/ez docker:start 

Then the site can not connect to the database anymore.

ConnectionException
An exception occurred in driver: SQLSTATE[HY000] [1049] Unknown database ‘ezplatform’

Idem with adminer

http://localhost:XX084/?server=db&username=root&db=ezplatform

My parameter file contains the following parameters:

env(DATABASE_HOST): localhost
env(DATABASE_PORT): null
env(DATABASE_NAME): ezplatform
env(DATABASE_USER): root
env(DATABASE_PASSWORD): null

#2

Just add

    extra_hosts:
        - "foo.lxc:10.0.3.23"

Under

services:
    engine:

#3

ho!
I just found the password!
It is in the file docker-compose.yml

services:
    db:
        environment:
            - MYSQL_ROOT_PASSWORD=ezplatform

And at the same time, I realize that my database is not persisted when I delete my image.

So with this password I can connect but my database has permanently disappeared. Fortunately I did not have anything special about it.
How can I recreate it?

I will see in the manual installation doc.

I’m going to see it to persist specifying the volume in my docker-composer.yml

    volumes:
        - '${PROJECTCOMPOSEPATH}/${PROVISIONINGFOLDERNAME}/dev/db/:/var/lib/mysql:rw'

#4

YaTa !

My docker was mounted without the ‘volumes’ for the db service.

I down so. then up.

~/ez docker:down && ~/ez docker:up

I created the database (via admin)
I enter the engine and launch the ezplatform installation script.

~/ez docker:enter
cd project/ezplatform/
/usr/bin/mysql -u root -e 'create database ezplatform;'
php -d memory_limit=-1 bin/console ezplatform:install studio-clean

My website works!

I down and I up.
Like the db service is persisted my site still works :slight_smile:


#5

Hello @remy_php,

Sorry I did not check the forum recently… :confused:

Actually, you should not use down and up that often, stop and start are totally fine. It maintains your data as the containers are not removed.

If you want to remove everything you should ez clean and then ez create again. ez create will re run the install process. you should not have to bin/console ezplatform:install yourself.

Also you have ez dumpdata and ez importdata to dump and import your current state of the database.
Useful to share with coworkers.

Hote it helps (even if it is a late answer!)


#6

Thank you for that clarification @Plopix .

I might have other things to do and your advice will be useful.
And it can help others :slight_smile:


#7

I’ve done something wrong with my site I’d like to start from scratch.
I made a ez dumpdata and saved the generated files (data/ezplatform.sql.gz and data/storage.tar.gz)

But I don’t have any original dump to restore. (ez importdata)

How can I empty my storage and restore a blank database?


#8

I’ve tested this well:

but it gives a very strange result…

The definitions of my contenttype are always present…


#9

It actually works… It’s just that caches are particularly tough.

And we also need to clear the table kaliop_migrations


#10

yes to restart from scratch, like real scratch with empty ez what you’ve done is correct.
I suppose an ez stop redis; ez start redis would be useful to clear the redis cache as well. That might be why you have seen the old content type for a while