0

I have a docker container running /bin/bash

So I can attach to it and run commands like

docker attach <container id>
bash# apt-get install package

Is there a way I can do this in a single docker command instead, maybe something like this:

docker attach <container id> "apt-get install package"

1 Answer 1

2

This should work.

echo 'sudo apt-get install package' | docker attach <container id>

Sign up to request clarification or add additional context in comments.

2 Comments

thanks, thats a nice workaround, but is there also a way to then see the output of that command on stdout?
How about echo 'sudo apt-get install package' | docker attach <container id> && docker logs -f <container id> ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.