Showing posts with label bash shell. Show all posts
Showing posts with label bash shell. Show all posts

Saturday, 9 May 2020

Docker: Run the bash shell in interactive mode

Below command pulls python image if not exist and runs the bash shell in interactive mode.

docker run -it --rm python:3 /bin/bash

-it: Run the container in interactive mode.
--rm: Remove the container after its execution
/bin/bash: Command to be executed.

$docker run -it --rm python:3 /bin/bash
root@8e7afceedc1e:/#

root@8e7afceedc1e:/# pwd
/
root@8e7afceedc1e:/# ls -a
.  ..  .dockerenv  bin boot  dev  etc home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@8e7afceedc1e:/#

Execute the command ‘exit’ to come out of the container.

root@8e7afceedc1e:/# exit
exit
$


Previous                                                    Next                                                    Home

Docker: Open bash shell of docker container

Just add the command /bin/bash while running the container.

Step 1: Open terminal and execute below command
docker run -t -i ubuntu /bin/bash

$docker run -t -i ubuntu /bin/bash
root@b63f436f0087:/# echo "Hello World"
Hello World
root@b63f436f0087:/#

Execute the command ‘exit’ to comeout of bash shell.

root@b63f436f0087:/# exit
exit
$



Previous                                                    Next                                                    Home