I want to try out installing a program inside of Ubuntu in docker,
So I just run directly from the command prompt
docker run --name ubuntu_test ubuntu:16.04
docker exec -it ubuntu_test bash
but it doesn't work, it says container not running? how can I run the bash without setting up a dockerfile? (I tried using dockerfile, but it doesn't work because of interactive installer problem)
So I thought maybe directly install it from the bash could work.
The problem is that your command doesn't keep the proccess alive nor does it keep it in the background so the container finishes its work and stops running. Its like docker run hello-world
which prints some stuff and exits.
docker run -it --name ubuntu_test ubuntu:16.04
will work for you. The documentation explains:
For interactive processes (like a shell), you must use -i -t together in order to allocate a tty for the container process. -i -t is often written -it
An alternative would be to run the container in detached mode (-d) and give it a long running command so that it doesn't exit immediately:
docker run --name ubuntu_test -d ubuntu:16.04 sleep 300
docker exec -it ubuntu_test bash
You are failing to start the container. Try this:
docker run -itd ubuntu:16.04 bash
-i, --interactive - Keep STDIN open even if not attached
-t, --tty - Allocate a pseudo-TTY
-d, --detach - Run container in background and print container ID
After this command list all your containers(docker ps
):
Now you can attach to your running container and do some stuff:
docker exec -it 82d0bb7754e7 /bin/bash
(in this case, to indicate the container I used the ID, you can also use container name)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With