Search code examples
dockerfig

Fig: how do I run commands on an existing container?


I have two containers running with fig up: web and db. I'd like to get some info about the environment where the web container is running: what env variables are set, read some logs that the web server has written, etc.

I know that containers are a bit like processes and you don't "log into" processes, but they're also in a way similar to VMs and you do log into them...

How can I achieve that?


Solution

  • first you want to list your running containers:

    docker ps
    

    Then you can run a bash shell inside your running container using its ID or name:

    docker exec -i -t 665b4a1e17b6 bash
    docker exec -i -t container_name bash