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

How about adding document for docker compose exec? #5328

Closed
quroom opened this issue Aug 28, 2024 · 4 comments
Closed

How about adding document for docker compose exec? #5328

quroom opened this issue Aug 28, 2024 · 4 comments

Comments

@quroom
Copy link
Contributor

quroom commented Aug 28, 2024

Description

https://github.com/cookiecutter/cookiecutter-django/blob/master/docs/developing-locally-docker.rst#execute-management-commands

The document says exec doesn't work for running management commands.

But actually we can use it with /entrypoint script as he said

I tested it as he said, like docker compose -f docker-compose.local.yml exec django /entrypoint python3 manage.py createsuperuser
It works fine.

How do you think just adding that command to document?

Rationale

Just add how to use command to document.

@cookiecutter cookiecutter deleted a comment Aug 28, 2024
@foarsitter
Copy link
Collaborator

docker exec is something different than docker compose exec. docker exec django doesn't work since the container name or ID is required.

@foarsitter foarsitter added the answered Automatically closed as answered after a custom delay label Aug 28, 2024
@quroom
Copy link
Contributor Author

quroom commented Aug 28, 2024

docker exec is something different than docker compose exec. docker exec django doesn't work since the container name or ID is required.

That's right. I am talking about docker compose exec.
docker exec doesn't work without container id or something as you said.
But as I said and the comment in #3224 , we can do it without running new container.
Let's say django container is running, then we can easily and faster do same thing with docker compose exec
But without /entrypoint, It wouldn't work as we expect.
So I think it's better to describe how to use it in document like below between docker compose run and docker exec explanation

As with any shell command that we wish to run in our container, this is done using the docker compose -f docker-compose.local.yml run --rm command:

$ docker compose -f docker-compose.local.yml run --rm django python manage.py migrate
$ docker compose -f docker-compose.local.yml run --rm django python manage.py createsuperuser

If django container is alreay run, you can do it same thing with docker compose exec.

$ docker compose -f docker-compose.local.yml exec django /entrypoint python manage.py migrate
$ docker compose -f docker-compose.local.yml exec django /entrypoint python manage.py createsuperuser

Here, django is the target service we are executing the commands against. Also, please note that the docker exec does not work for running management commands.

@github-actions github-actions bot removed the answered Automatically closed as answered after a custom delay label Aug 28, 2024
@foarsitter
Copy link
Collaborator

foarsitter commented Aug 28, 2024

Yes you are correct.

As a mater of fact, we are trying to make the entrypoint script obsolete in #4862 and #4861 and in lesser extend #5327

If these PR's get merged /entrypoint ins't longer required and exec would work as expected. Can you review these PR?

@quroom
Copy link
Contributor Author

quroom commented Aug 28, 2024

Yes you are correct.

As a mater of fact, we are trying to make the entrypoint script obsolete in #4862 and #4861 and in lesser extend #5327

If these PR's get merged /entrypoint ins't longer required and exec would work as expected. Can you review these PR?

I am not reviewer :)
But LGTM!
I hope It would be merged soon.
Thanks for your job.

I close issue.

@quroom quroom closed this as completed Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants