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

[DOCS] Amend docs about using docker-compose stop instead of docker-compose down #289

Merged
merged 1 commit into from
Sep 7, 2022

Conversation

dansmart-box
Copy link
Contributor

Added note in docker-setup to add learning about docker-compose down preventing DB being lost.

@dansmart-box dansmart-box added the documentation Improvements or additions to documentation label Sep 6, 2022
@@ -57,6 +57,10 @@ for development environments.

* `docker-compose up`

* Use `docker-compose stop` to stop the container (without removing the volumes).

> Don't use `docker-compose down` to temporarily stop the container. If you do, the volumes will be removed, meaning that the contents of your DB will be lost. After using `docker-compose stop`, continue to use `docker-compose up` to bring the container and volumes up as before, and the DB will still exist and work as expected. (See https://stackoverflow.com/questions/46428420/docker-compose-up-down-stop-start-difference and https://forums.docker.com/t/why-docker-compose-down-deletes-my-volume-how-to-define-volume-as-external/67433/11)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better off clarifying that docker-compose up is to be done in the first instance, then docker-compose start and docker-compose stop for routine work on the project

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes good point. I'll make that change, and squash the commits also.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated @jonny-bull

@dansmart-box dansmart-box force-pushed the update_docs_for_docker_stop branch from daf9a19 to b59edc5 Compare September 6, 2022 15:57
@@ -55,7 +55,13 @@ for development environments.

> This only needs to be called once to build the image(s)

* `docker-compose up`
* `docker-compose up` first
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be more verbose here.

Use docker-compose up to build the containers. You'll only need to use this the first time.

Can probably remove the line above as a bonus


* Use `docker-compose stop` to stop the container (without removing the volumes).

> Don't use `docker-compose down` to temporarily stop the container. If you do, the volumes will be removed, meaning that the contents of your DB will be lost. After using `docker-compose stop`, continue to use `docker-compose start` to bring the container and volumes up as before, and the DB will still exist and work as expected. (See https://stackoverflow.com/questions/46428420/docker-compose-up-down-stop-start-difference and https://forums.docker.com/t/why-docker-compose-down-deletes-my-volume-how-to-define-volume-as-external/67433/11)
Copy link
Contributor

@jonny-bull jonny-bull Sep 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can be cut down significantly more now you've added in the lines above

Using docker-compose down stops containers but also removes them. This will lead to loss of data.

(You know, you can still use docker-compose down but be aware of the risk involved)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, very useful, I was struggling to be less verbose. Incorporating those changes now 👍

@dansmart-box dansmart-box force-pushed the update_docs_for_docker_stop branch from b59edc5 to 5c754d4 Compare September 6, 2022 16:09
@dansmart-box dansmart-box merged commit 2b67faf into main Sep 7, 2022
@dansmart-box dansmart-box deleted the update_docs_for_docker_stop branch September 7, 2022 08:25
@jenkoian
Copy link
Contributor

jenkoian commented Sep 7, 2022

Another thing to consider if data loss in this way remains a problem is storing the db volume on the host, e.g. https://github.com/symfony/recipes/blob/main/doctrine/doctrine-bundle/2.4/manifest.json#L35-L36

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

Successfully merging this pull request may close these issues.

3 participants