Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Update setup.rst #1590

Closed
wants to merge 1 commit into from
Closed

Update setup.rst #1590

wants to merge 1 commit into from

Conversation

a-waider
Copy link

In my installation environment the setup didn't work. I think running docker exec instead of docker-compose run is more error free. Or is there any specific reason why docker-compose run is used?

In my installation environment the setup didn't work. I think running `docker exec` instead of `docker-compose run` is more error free. Or is there any specific reason why `docker-compose run` is used?
@torwag
Copy link

torwag commented Feb 3, 2022

According to the answers on a similar question on
almighty stackoverflow

docker-compose exec: will run docker exec to start a new process/command inside an existing, running container

docker-compose run: starts a new container for interactively executing the specified command, i.e. executing docker run

docker-compose exec is basically identical to docker exec. It is a debugging tool that can run an additional command inside a running container. It runs in the same environment as the container's main process, with the same container-private filesystem. It is not a child process of the main process, and if the main process has an entrypoint wrapper script that sets environment variables, it won't get to see those. The additional command is frequently a debugging shell, and docker-compose exec defaults to the docker exec -it options.

# Get a debugging shell in a running container:
docker-compose exec app bash

# Basically equivalent to:
docker exec -it project_app_1 bash

Which leaves the question if identical, why does one work for you and not the other?

@mskg
Copy link

mskg commented Feb 3, 2022

Your description contains the answer. Exec allows you to connect to a running container, run creates a new container before running.

The image is a daemon (webserver, 3 services for processing files, database, ...) . You start it (docker-compose up -d), and can run commands inside using exec.

@torwag
Copy link

torwag commented Feb 3, 2022

Yeah, I just came here again to say this...
Things get mixed up.... docker-compose vs. docker and exec vs. run.
If I understand the setup documentation correctly, you need to use "exec" and not run, as you want to create the superuser stuff inside the already existing container. Unlike whatever the script does, changes stuff on the same volume share. But yeah, "exec" should be more save.

@mskg
Copy link

mskg commented Feb 3, 2022

Yes and no. Because you map out all files that are required to rerun it in a specific state it will also work. And if there is not other container running, it is totally valid to do it like that (use run).

@mskg
Copy link

mskg commented Feb 3, 2022

I checked the change you did. As he starts the container three steps before it, one should use exec here. There is some other places where the container needs to be stopped before the commands are execute, there the run is OK.

Copy link

@mskg mskg left a comment

Choose a reason for hiding this comment

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

As the container is already up in step 1, exec should be used.

@a-waider a-waider closed this by deleting the head repository Mar 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants