getporter / porter

Porter enables you to package your application artifact, client tools, configuration and deployment logic together as an installer that you can distribute, and install with a single command.
https://porter.sh
Apache License 2.0
1.23k stars 206 forks source link

access the porter installed container after install finish #803

Open ffoysal opened 4 years ago

ffoysal commented 4 years ago

Describe the bug

after running porter install is it possible to access the container that being used during porter install so that we can see the files being used or generated during porter install.

To Reproduce

NA

Expected behavior

something like this ... docker start <porter-install-container> docker exec -it <porter-install-container> bash

carolynvs commented 4 years ago

Yeah this would be super helpful. 👍

There are two ways we could go about this (maybe more):

  1. Commit the container at the end of the install so you can use the image. It wouldn't let you see env vars and state, just the file system. I have a hunch this is easier/quicker for us to do.

    porter install --debug
    
    Okay! All done and we kept a image for you to look at. 
    Run the following command to see what the container looked like at the end:
    
    docker run -it --rm porter-debug-last
    $ 
  2. We can add a flag that says start the container and leave it running.

    $ porter install --debug --pause-for-attach
    
    Okay! All done and it is ready for you to attach to look at. 
    Run the following command to see the container. 
    Once you are done, run `porter debug cleanup` to remove the running container.
    
    docker exec -it porter-debug bash
    $
squillace commented 4 years ago

I like 2 (of course), but that's just a vote here. This is part of the larger introspection issue: how do you vet a bundle, understand it, and so on, prior to, during, and subsequent to using it? There's a metaissue here. :-)

carolynvs commented 2 years ago

You can set the environment variable CLEANUP_CONTAINERS=true and your stopped container will be left behind for you to troubleshoot. To re-enter the container, run docker ps to see the container id, use docker commit CONTAINER_ID NEWIMAGENAME, then docker run --rm -it --entrypoint bash NEWIMAGENAME to look around.

I'm keeping this open as a documentation issue. Let's take this info above and put it into our bundle author docs as a task "e.g. debugging a bundle"

carolynvs commented 2 years ago

Turns out I had more interesting ideas for how to support this #1727. Since that may not happen for a while, I'll keep this open to document the workaround today.

carolynvs commented 2 years ago

For now let's just document CLEANUP_CONTAINERS on the website. It can be a task for bundle authors to help them troubleshoot a bundle when they are writing one.