exec: run a command in a docker container

Suppose you started a container ubuntu with the command

docker run -d --name myubuntu ubuntu

To run some bash command inside this container you need to use the docker exec command.

For example, a listing

docker exec myubuntu ls

bin boot dev etc home lib lib32 lib64 libx32 media mnt opt proc root run sbin srv sys tmp usr var

Nuances of using Linux and Windows

If the operating system on which you installed Docker is Linux you can run ls with

docker exec myubuntu ls

and also with

docker exec myubuntu ls /

In Windows only the following will work

Article author: Andrei Olegovich