Added '-q' as a default docker build command to fix issue #53 #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added '-q' as a default docker build command to fix issue #53 where 'eb local run' incorrectly parses last word of docker build stdout as image id to docker run
Issue #, if available:
#53
Description of changes:
As documented in issue #53, there is an issue when running 'eb local run' to run a docker image locally via the eb cli.
The problem is documented in detail below but in short is caused by the eb cli parsing the last line of docker build stdout (which is the time taken to complete the stage)
as the image id which is then used as the image id to the docker run command.
I looked at the flow of getting the image ID to use in the container run command and found that this function is the one that builds the image and returns an image id (for use in the container run function):
ebcli/containers/commands.py line 49
Now there are two possible sources of error (and solutions here) - Solution 1 is to alter the _grab_built_image_id() function or Solution 2: Alter the function that runs the actual docker build command (_run_live() or build_img()) so that the output is formatted correctly.
The _run_live() function is called with
args = ['docker', 'build'] + opts + [docker_path]
The function:
ebcli/containers/commands.py line 277
As you can see, it then calls exec_cmd_live() which is:
ebcli/lib/utils.py line 236
exec_cmd_live_output = exec_cmd
which is:
ebcli/lib/utils.py line 199
exec_cmd() actually executes the docker build command with:
This basically runs a system command and returns the running process so that the output logs can be read.
So I then tried to re-create the docker build command that generates the build logs we are seeing when running eb local run and found that this command does that:
Note the progress plain param to the docker build call - this is what produces the build output we see. Last line of output from above docker build command:
And there's the 0.0s that's being used by the AWS eb cli as the image id.
So then solution 2: Instead of instructing docker to produce those build logs, the docker build command could be run quietly as below:
Which will just write out the desired image id.
The issue with running the docker build quietly though is that we won't see the build logs from eb local run which could bother some people but creating rules on the text output from docker build is flimsy as it will break if the output from docker build changes again.
I tested solution 2 proposed above, changing the docker build command by altering this function:
ebcli/containers/commands.py line 49
FROM
TO
Added -q to always run docker build quietly and thus only output the image id
The command eb local run --port 3838 then ran successfully
This fix works and should work on all platforms as I'm pretty sure that docker build quietly will always
output the same (image id only) on all platforms
(as documented here)
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.