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

docker-compose up Error #181

Closed
aadeshkulkarni opened this issue Mar 10, 2024 · 10 comments · Fixed by #182
Closed

docker-compose up Error #181

aadeshkulkarni opened this issue Mar 10, 2024 · 10 comments · Fixed by #182

Comments

@aadeshkulkarni
Copy link

aadeshkulkarni commented Mar 10, 2024

Description:

docker-compose up returns the following errors:

  1. Mounts denied error for the db host volume address. (for Mac specifically) ( Screenshot attached below )
    (Which when resolved by changing the host address, returns the next error)

  2. Error P1001: Can't reach database server.
    The cms-app docker container runs the migration script even before the cms-db docker container is up. (Error Screenshot attached below)

Details on Issue 2:

By default, Docker Compose only ensures that the services listed under the depends_on property are started before the dependent service. This means that Compose doesn't guarantee that these services are fully operational and ready to process requests, but only that their containers are running.

It is however possible to set conditions to define when one service should start or wait for another service to reach a specific state. These conditions are defined in the condition property and take three possible values: service_started, service_healthy, and service_completed_successfully.

Proposed Solution:

  1. Investigate and resolve the issue with the Host volume address to ensure the build mount is successful.
  2. Set the appropriate conditions for the cms-app container to wait for the cms-db container to reach a specific state before running the migration script.

Steps to Reproduce the issue

  1. Run the docker-compose up command on a local machine.
  2. Monitor the logs and observe the build mount failure and premature migration script execution.
  3. Review the Docker Compose file for the services' dependencies and conditions.
  4. Implement the necessary changes to resolve the issues.

Additional resources

https://www.warp.dev/terminus/docker-compose-depends-on

Proposed solution

https://github.com/peter-evans/docker-compose-healthcheck

Screenshots

Issue 1 (Mount fail)

Screenshot 2024-03-10 at 4 45 57 PM

Issue 2 (container cms-app starting before starting cms-db service is healthy)

Screenshot 2024-03-10 at 5 14 13 PM

@geekyharsh05
Copy link
Contributor

geekyharsh05 commented Mar 10, 2024

@aadeshkulkarni you can configure the file sharing by going to settings. it works for me.

Screenshot 2024-03-10 at 6 00 27 PM

@aadeshkulkarni
Copy link
Author

aadeshkulkarni commented Mar 10, 2024

@aadeshkulkarni you can configure the file sharing by going to settings. it works for me.

Screenshot 2024-03-10 at 6 00 27 PM

I have tried doing this. But Docker does not let me create a directory for that address. (Using MacOS)
There is a probability that something must be wrong on my end here, debugging rn.

There was one more individual who was facing this issue in discord
Message link - https://discord.com/channels/1171768226691162162/1178318174920380566/1216292791911714938

Screenshot 2024-03-10 at 6 11 45 PM

@devsargam
Copy link
Collaborator

hey @aadeshkulkarni, I am the author of Dockerfile for this repo.
Try @geekyharsh05 approach or change the postgres volume in docker-compose.yml

TY

@devsargam
Copy link
Collaborator

Also, @aadeshkulkarni this has been resolved.

It's just the way docker is wired in mac os.

@aadeshkulkarni
Copy link
Author

Configuring the file sharing by going to settings didn't work for me.

I have changed the postgres volume to make it work for now.

Can you confirm if Issue#2 is reproducible ? @devsargam & @geekyharsh05
This issue only occurs during initial app setup (for fresh first time db migrations)
If you've already performed db migrations, you might need to clear your volumes to test this.

@devsargam
Copy link
Collaborator

@aadeshkulkarni haven't reproduced but your point seems valid.

@geekyharsh05
Copy link
Contributor

geekyharsh05 commented Mar 10, 2024

@devsargam what if you try this approach, instead of using absolute path we can use relative path, so it'll become easy for anyone to setup the project using docker. Is it a right approach?

volumes:
      - ./postgres-data:/var/lib/postgresql/data

@aadeshkulkarni
Copy link
Author

aadeshkulkarni commented Mar 11, 2024

@devsargam what if you try this approach, instead of using absolute path we can use relative path, so it'll become easy for anyone to setup the project using docker. Is it a right approach?

volumes:
      - ./postgres-data:/var/lib/postgresql/data

This PR #182 has the solution @geekyharsh05 mentioned above for issue #1.

It also has issue #2 resolution. but keeping the PR as draft until #2 is reproducible by someone else.

Edit:
Issue#2 is reproducible:
Discord > os-doubts-and-discussions:

Screenshot 2024-03-11 at 7 07 10 AM

@devsargam
Copy link
Collaborator

Just in case did you do
docker rmi
docker compose up --build?

@aadeshkulkarni
Copy link
Author

Yes,

removed db volume on the local host by deleting the/postgres-data directory. (to clear all previous db migrations)

Then docker compose up with or without --build should trigger the issue

@aadeshkulkarni aadeshkulkarni changed the title Docker compose up Fails intermittently docker-compose up Error Mar 12, 2024
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

Successfully merging a pull request may close this issue.

3 participants