shipping-docker / php-app

A containerized Laravel application
278 stars 73 forks source link

Docker-compose update not working #6

Closed lukasoppermann closed 8 years ago

lukasoppermann commented 8 years ago

Hey,

I am trying to follow your course, but I am having trouble with updating the db.

I created a db and it worked. However now I can to rename this db and change the env files. I changed my docker-compose.yml but when I do docker-compose down and docker-compose up it still has only the old db on the mysql container. Any ideas what I could be messing up?

fideloper commented 8 years ago

The later videos will give some clues to this. When you run docker compose down, it doesn't destroy the data container, so when you re-create everything (docker compose up), it reuses it.

The MySQL container has code to test if existing db files exist and if it does, it re-uses those - this your old database will exist.

You can destroy the volume after running docker compose down I'd you no longer want that data - that's covered in the video in volumes.

On Thu, Sep 15, 2016 at 11:06 Lukas Oppermann notifications@github.com wrote:

Hey,

I am trying to follow your course, but I am having trouble with updating the db.

I created a db and it worked. However now I can to rename this db and change the env files. I changed my docker-compose.yml but when I do docker-compose down and docker-compose up it still has only the old db on the mysql container. Any ideas what I could be messing up?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/shipping-docker/php-app/issues/6, or mute the thread https://github.com/notifications/unsubscribe-auth/AAch07IN8PEwP9AN3zTbWZ7ieQv2WJDUks5qqW0QgaJpZM4J-DJG .

fideloper commented 8 years ago

(Sorry for auto correct typos, im on my phone ) On Thu, Sep 15, 2016 at 11:26 Chris Fidao fideloper@gmail.com wrote:

The later videos will give some clues to this. When you run docker compose down, it doesn't destroy the data container, so when you re-create everything (docker compose up), it reuses it.

The MySQL container has code to test if existing db files exist and if it does, it re-uses those - this your old database will exist.

You can destroy the volume after running docker compose down I'd you no longer want that data - that's covered in the video in volumes.

On Thu, Sep 15, 2016 at 11:06 Lukas Oppermann notifications@github.com wrote:

Hey,

I am trying to follow your course, but I am having trouble with updating the db.

I created a db and it worked. However now I can to rename this db and change the env files. I changed my docker-compose.yml but when I do docker-compose down and docker-compose up it still has only the old db on the mysql container. Any ideas what I could be messing up?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/shipping-docker/php-app/issues/6, or mute the thread https://github.com/notifications/unsubscribe-auth/AAch07IN8PEwP9AN3zTbWZ7ieQv2WJDUks5qqW0QgaJpZM4J-DJG .

lukasoppermann commented 8 years ago

Thanks, actually I think my problem was I was thinking the container actually builds a db from the environment variables, but this is not true, is it? That is composer installing laravel, which actually does create the database.

lukasoppermann commented 8 years ago

Hey, I understood everything now and got it working. What I missed is, that of course you need to delete and recreate the volume to change the mysql root password. As I think you mentioned in your video, some info can be found here: https://hub.docker.com/_/mysql/

fideloper commented 8 years ago

The environment variables in the docker-compose.yml file do tell the mysql container to create the database there.

I don't believe Laravel migrations will create a database for you, just tables within a database.

However the container will ONLY create a database there the first time it's spun up. If you then change the environment variable, the container won't rename or create a new database for you. If it finds ANY pre-existing data, it will just use what's already there. The ENV variables only take effect when you first spin it up.

Whoops we were typing at the same time, Github just updated your response - looks like you found that out!