Run commands through

I am trying to run commands through a Docker container. I am able to successfully create and print the containers logs to console however, I want to to be able to run commands once connected to the container. I am using Flask as I am creating a web based console for managing the container. I have it connect to to the container but want to send commands once connected and not send a command as the container is being created."ubuntu:latest", "echo hello world") will create the container and echo hello world but I am wanting it so I am able to send commands once the container is already created. I am using the official lib from Docker.

def dashboard():
    container ='ubuntu:latest', detach=True)
    for line in container.logs(stream=True):
    return "<h1>Container Created!</h1>"

1 answer

  • answered 2019-02-10 20:21 Martin do santos Documentation has the answer: Execute

    Since execute is deprecated, you have to use exec_create and exec_start.

    So, you have to use to get the Id of the container, but it should be enough.

    Hope it helps.