1

I'm using org-mode + org-babel to execute Bash commands that execute Docker commands. Here's an example:

#+BEGIN_SRC sh :exports both :dir ~/Dev/Docker/sample

sudo docker build -t tompurl/nginx .

#+END_SRC

When I run this command within Emacs I get the following output:

+RESULTS:

| Sending        | build                | context                   | to                                               | Docker                | daemon                | 4.096                 | kB       |           |               |          |          |                |          |       |               |           |                                             |                              |                                      |                  |                                     |                      |                          |                                     |          |     |                                               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |                |          |     |      |       |     |             |           |             |
| Step           | 1                    | :                         | FROM                                             | ubuntu:16.04          |                       |                       |          |           |               |          |          |                |          |       |               |           |                                             |                              |                                      |                  |                                     |                      |                          |                                     |          |     |                                               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |                |          |     |      |       |     |             |           |             |
| --->           | 104bec311bcd         |                           |                                                  |                       |                       |                       |          |           |               |          |          |                |          |       |               |           |                                             |                              |                                      |                  |                                     |                      |                          |                                     |          |     |                                               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |                |          |     |      |       |     |             |           |             |
| Step           | 2                    | :                         | MAINTAINER                                       | Tom                   | Purl                  | <tom@tompurl.com>     |          |           |               |          |          |                |          |       |               |           |                                             |                              |                                      |                  |                                     |                      |                          |                                     |          |     |                                               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |                |          |     |      |       |     |             |           |             |
| --->           | Running              | in                        | dcd4c9dca196                                     |                       |                       |                       |          |           |               |          |          |                |          |       |               |           |                                             |                              |                                      |                  |                                     |                      |                          |                                     |          |     |                                               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |                |          |     |      |       |     |             |           |             |
| --->           | 282dcb00cc8b         |                           |                                                  |                       |                       |                       |          |           |               |          |          |                |          |       |               |           |                                             |                              |                                      |                  |                                     |                      |                          |                                     |          |     |                                               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |                |          |     |      |       |     |             |           |             |
| Removing       | intermediate         | container                 | dcd4c9dca196                                     |                       |                       |                       |          |           |               |          |          |                |          |       |               |           |                                             |                              |                                      |                  |                                     |                      |                          |                                     |          |     |                                               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |                |          |     |      |       |     |             |           |             |
| Step           | 3                    | :                         | ENV                                              | REFRESHED_AT          | 2017-01-03            |                       |          |           |               |          |          |                |          |       |               |           |                                             |                              |                                      |                  |                                     |                      |                          |                                     |          |     |                                               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |                |          |     |      |       |     |             |           |             |
| --->           | Running              | in                        | 5c0aef4cfeca                                     |                       |                       |                       |          |           |               |          |          |                |          |       |               |           |                                             |                              |                                      |                  |                                     |                      |                          |                                     |          |     |                                               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |                |          |     |      |       |     |             |           |             |
| --->           | 6dc275877c48         |                           |                                                  |                       |                       |                       |          |           |               |          |          |                |          |       |               |           |                                             |                              |                                      |                  |                                     |                      |                          |                                     |          |     |                                               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |               |          |     |                |          |     |      |       |     |             |           |             |
| 

This is just the first 10 lines, there are well over 100 in the total output. Notice how the output seems to be squeezed into a table.

Here's the output from the same command when executed from the command line:

$ sudo docker build .                            
Sending build context to Docker daemon 4.096 kB
Step 1 : FROM ubuntu:16.04
 ---> 104bec311bcd
Step 2 : MAINTAINER Tom Purl "<tom@tompurl.com>"
 ---> Using cache
 ---> 282dcb00cc8b
Step 3 : ENV REFRESHED_AT 2017-01-03
 ---> Using cache
 ---> 6dc275877c48
Step 4 : RUN apt-get -yqq update && apt-get -yqq install nginx
 ---> Using cache
 ---> 91a8bef9ea0b
Step 5 : RUN mkdir -p /var/www/html/website
 ---> Using cache
 ---> c28fa568b3c2
Step 6 : ADD global.conf /etc/nginx/conf.d/
 ---> Using cache
 ---> 365c3e022248
Step 7 : ADD nginx.conf /etc/nginx/nginx.conf
 ---> Using cache
 ---> 726d0c223e77
Step 8 : EXPOSE 80
 ---> Using cache
 ---> 9035336945b0
Successfully built 9035336945b0

Is there something that I'm doing to squeeze everything into a table like this?

  • 1
    I'm on Windows now, so I can't test, but I think you can fix this by adding :results verbatim to the #+BEGIN_SRC line. (The default is to guess if the output is tabular data nad make a table if it is, I guess Babel's guess is wrong in this case; verbatim tells Babel the output is just literal text.) – Omar Jan 3 '17 at 19:28
  • Yup, that did it Omar, thanks! Would you like to answer so I can accept it or should I answer it myself? – Tom Purl Jan 3 '17 at 20:11
  • I've added an answer now. – Omar Jan 4 '17 at 4:56
2

The default for Babel results blocks (in most languages) is try to guess what the best format is. Here Babel seems to be guessing incorrectly that the output of your block is tabular data. You can use :results verbatim to tell Babel that the result should be treated as literal text. (There is also :results table to force the results to be in a table.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.