24

So I have successfully downloaded and got running the dockerfile/nginx image from the registry. How can I now access its file system by firing up a bash terminal on it?

Maybe I am missing something conceptually here. Do I need to ssh into it? thanks

1

1 Answer 1

32

You can start an interactive shell in a new image:

sudo docker run -i -t nginx /bin/bash

This gives you access to the container and you can change things. When done you need to save your changes in a new reusable image:

sudo docker commit <container_id> <some_name>

This approach makes sense for testing. Usually you would use Dockerfiles to automate this.

In case your image has a default entry point you can overwrite it:

docker run -i -t --entrypoint /bin/bash nginx
Sign up to request clarification or add additional context in comments.

4 Comments

thanks, I get 'invalid option /bin/bash' so I am guessing that the creators of the image have disabled or removed bash?
How do I save my changes into a new reusable image without first exiting the running container?
open a new terminal and use sudo docker commit <container_id> <some_name>
Some images have both an ENTRYPOINT and CMD, try docker run -it --entrypoint /bin/bash nginx -i

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.