How do I run a command on an already existing Docker container

0 votes

I created a container with -d flag

docker run -d shykes/pybuilder bin/bash

And the container exits

CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS                      PORTS               NAMES
d6c45e8cc5f0        shykes/pybuilder:latest   "bin/bash"          41 minutes ago      Exited (0) 2 seconds ago                        clever_bardeen

Now I'd like to quit the system after running a few commands. Simply to receive a reaction.

I attempted to turn on the machine. I attempted to attach. I assumed I could call run with a container, but it doesn't appear like this is possible. Start appears to run and then disappear swiftly.

After departing, I'd like to return to interactive mode.

I ran:

docker attach d6c45e8cc5f0

And got this output:

2014/10/01 22:33:34 You cannot attach to a stopped container, start it first

If it is started, it exits anyway. Help.

Apr 28, 2022 in Docker by Abhijeet
• 180 points

edited 5 days ago 5 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP