How do I run a linux command inside a docker container?



  • To run a linux command inside a docker container:

     --rm      Automatically remove the container when it exits
    
    $ sudo docker run --rm centos:7 echo "hello world"
    hello world
    

    It ran the command inside a docker container, displayed the output and finished. While it ran it was self contained, After the command finished running the container was automatically removed.


Log in to reply
 

© Lightnetics 2024