0

I'd like to learn the Dockerfile from a very simple start, so here's my Dockfile:

FROM ubuntu
ENTRYPOINT /bin/bash

however, after building the image and run the container, I find that I can't run the bash commands. For example, if I type:

# clear

The container seems to get stuck running in an infinite loop. So why does that happen? How can I fix it?

2
  • Did you add a -it to your docker run command? docker run -it --rm --entrypoint /bin/bash ubuntu -c "clear" seems to work... Commented Sep 27, 2016 at 18:15
  • 2
    Please add the command that you used to run the container, and the output in your container's bash. Commented Sep 27, 2016 at 18:21

2 Answers 2

3

How are you running the container? Note that you have to pass the options -i in order to keep STDIN open and the -t to allocate a pseudo-TTY.

Below you can find an example:

docker run -i -t my-image

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

1 Comment

Yeas, I forget to add -i while running the container! Thank you!
0

docker run -it ubuntu

Post this command, you will have a prompt like:

root@26f9e7a42517:/#

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.