Search code examples
dockercontainersibm-cloud

How can I run a command on an existing container in IBM Bluemix?


I've got an existing container on IBM Bluemix that is having issues while running.

I need to execute commands inside the container without stopping to get more information to allow me to debug the issue. The container doesn't have an SSH daemon enabled allowing me remote access.

Is there a way to execute remote commands and get the output?


Solution

  • In Docker 1.3, docker introduced the exec command allowing you to spawn a new process inside a running container.

    IBM Containers supports using this Docker command with containers running on IBM Bluemix using the IBM Containers plugin for the Cloud Foundry CLI.

    Use the following command to retrieve the container ID for the running instance you want to debug:

    $ cf ic ps
    

    Now, we can open a bash shell (or execute any available command) on the running container using the command below:

    $ cf ic exec -it <container_id> /bin/bash